Refactoring: Renamed CheckFunctionUsage to CheckUnusedFunctions

This commit is contained in:
Daniel Marjamäki 2009-06-07 22:12:20 +02:00
parent 6356db82a9
commit d7fa3e6dda
6 changed files with 39 additions and 40 deletions

View File

@ -9,12 +9,12 @@ OBJECTS = src/checkautovariables.o \
src/checkbufferoverrun.o \
src/checkclass.o \
src/checkdangerousfunctions.o \
src/checkfunctionusage.o \
src/checkheaders.o \
src/checkmemoryleak.o \
src/checkother.o \
src/checksecurity.o \
src/checkstl.o \
src/checkunusedfunctions.o \
src/cppcheck.o \
src/cppcheckexecutor.o \
src/errorlogger.o \
@ -36,7 +36,6 @@ TESTOBJ = test/testautovariables.o \
test/testdangerousfunctions.o \
test/testdivision.o \
test/testfilelister.o \
test/testfunctionusage.o \
test/testincompletestatement.o \
test/testmathlib.o \
test/testmemleak.o \
@ -51,18 +50,19 @@ TESTOBJ = test/testautovariables.o \
test/testsuite.o \
test/testtoken.o \
test/testtokenize.o \
test/testunusedfunctions.o \
test/testunusedprivfunc.o \
test/testunusedvar.o \
src/checkautovariables.o \
src/checkbufferoverrun.o \
src/checkclass.o \
src/checkdangerousfunctions.o \
src/checkfunctionusage.o \
src/checkheaders.o \
src/checkmemoryleak.o \
src/checkother.o \
src/checksecurity.o \
src/checkstl.o \
src/checkunusedfunctions.o \
src/cppcheck.o \
src/cppcheckexecutor.o \
src/errorlogger.o \
@ -118,16 +118,13 @@ src/checkclass.o: src/checkclass.cpp src/checkclass.h src/check.h src/tokenize.h
src/checkdangerousfunctions.o: src/checkdangerousfunctions.cpp src/checkdangerousfunctions.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/checkdangerousfunctions.o src/checkdangerousfunctions.cpp
src/checkfunctionusage.o: src/checkfunctionusage.cpp src/checkfunctionusage.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/checkfunctionusage.o src/checkfunctionusage.cpp
src/checkheaders.o: src/checkheaders.cpp src/checkheaders.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/filelister.h
$(CXX) $(CXXFLAGS) -c -o src/checkheaders.o src/checkheaders.cpp
src/checkmemoryleak.o: src/checkmemoryleak.cpp src/checkmemoryleak.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
src/checkmemoryleak.o: src/checkmemoryleak.cpp src/checkmemoryleak.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/mathlib.h
$(CXX) $(CXXFLAGS) -c -o src/checkmemoryleak.o src/checkmemoryleak.cpp
src/checkother.o: src/checkother.cpp src/checkother.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
src/checkother.o: src/checkother.cpp src/checkother.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/mathlib.h
$(CXX) $(CXXFLAGS) -c -o src/checkother.o src/checkother.cpp
src/checksecurity.o: src/checksecurity.cpp src/checksecurity.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
@ -136,10 +133,13 @@ src/checksecurity.o: src/checksecurity.cpp src/checksecurity.h src/check.h src/t
src/checkstl.o: src/checkstl.cpp src/checkstl.h src/check.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/checkstl.o src/checkstl.cpp
src/cppcheck.o: src/cppcheck.cpp src/cppcheck.h src/settings.h src/errorlogger.h src/checkfunctionusage.h src/tokenize.h src/token.h src/preprocessor.h src/filelister.h src/check.h
src/checkunusedfunctions.o: src/checkunusedfunctions.cpp src/checkunusedfunctions.h src/tokenize.h src/settings.h src/errorlogger.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/checkunusedfunctions.o src/checkunusedfunctions.cpp
src/cppcheck.o: src/cppcheck.cpp src/cppcheck.h src/settings.h src/errorlogger.h src/checkunusedfunctions.h src/tokenize.h src/token.h src/preprocessor.h src/filelister.h src/check.h
$(CXX) $(CXXFLAGS) -c -o src/cppcheck.o src/cppcheck.cpp
src/cppcheckexecutor.o: src/cppcheckexecutor.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h src/threadexecutor.h
src/cppcheckexecutor.o: src/cppcheckexecutor.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h src/threadexecutor.h
$(CXX) $(CXXFLAGS) -c -o src/cppcheckexecutor.o src/cppcheckexecutor.cpp
src/errorlogger.o: src/errorlogger.cpp src/errorlogger.h src/settings.h src/tokenize.h src/token.h
@ -154,13 +154,13 @@ src/main.o: src/main.cpp src/cppcheckexecutor.h src/errorlogger.h src/settings.h
src/mathlib.o: src/mathlib.cpp src/mathlib.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/mathlib.o src/mathlib.cpp
src/preprocessor.o: src/preprocessor.cpp src/preprocessor.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h
src/preprocessor.o: src/preprocessor.cpp src/preprocessor.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h src/filelister.h
$(CXX) $(CXXFLAGS) -c -o src/preprocessor.o src/preprocessor.cpp
src/settings.o: src/settings.cpp src/settings.h
$(CXX) $(CXXFLAGS) -c -o src/settings.o src/settings.cpp
src/threadexecutor.o: src/threadexecutor.cpp src/threadexecutor.h src/settings.h src/errorlogger.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h
src/threadexecutor.o: src/threadexecutor.cpp src/threadexecutor.h src/settings.h src/errorlogger.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h
$(CXX) $(CXXFLAGS) -c -o src/threadexecutor.o src/threadexecutor.cpp
src/token.o: src/token.cpp src/token.h
@ -184,7 +184,7 @@ test/testclass.o: test/testclass.cpp src/tokenize.h src/settings.h src/errorlogg
test/testconstructors.o: test/testconstructors.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkclass.h src/check.h test/testsuite.h
$(CXX) $(CXXFLAGS) -c -o test/testconstructors.o test/testconstructors.cpp
test/testcppcheck.o: test/testcppcheck.cpp test/testsuite.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkfunctionusage.h src/tokenize.h src/token.h
test/testcppcheck.o: test/testcppcheck.cpp test/testsuite.h src/errorlogger.h src/settings.h src/cppcheck.h src/checkunusedfunctions.h src/tokenize.h src/token.h
$(CXX) $(CXXFLAGS) -c -o test/testcppcheck.o test/testcppcheck.cpp
test/testdangerousfunctions.o: test/testdangerousfunctions.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkdangerousfunctions.h src/check.h test/testsuite.h
@ -196,9 +196,6 @@ test/testdivision.o: test/testdivision.cpp src/tokenize.h src/settings.h src/err
test/testfilelister.o: test/testfilelister.cpp test/testsuite.h src/errorlogger.h src/settings.h src/filelister.h
$(CXX) $(CXXFLAGS) -c -o test/testfilelister.o test/testfilelister.cpp
test/testfunctionusage.o: test/testfunctionusage.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h test/testsuite.h src/checkfunctionusage.h
$(CXX) $(CXXFLAGS) -c -o test/testfunctionusage.o test/testfunctionusage.cpp
test/testincompletestatement.o: test/testincompletestatement.cpp test/testsuite.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h src/checkother.h src/check.h
$(CXX) $(CXXFLAGS) -c -o test/testincompletestatement.o test/testincompletestatement.cpp
@ -241,6 +238,9 @@ test/testtoken.o: test/testtoken.cpp test/testsuite.h src/errorlogger.h src/sett
test/testtokenize.o: test/testtokenize.cpp test/testsuite.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h
$(CXX) $(CXXFLAGS) -c -o test/testtokenize.o test/testtokenize.cpp
test/testunusedfunctions.o: test/testunusedfunctions.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h test/testsuite.h src/checkunusedfunctions.h
$(CXX) $(CXXFLAGS) -c -o test/testunusedfunctions.o test/testunusedfunctions.cpp
test/testunusedprivfunc.o: test/testunusedprivfunc.cpp src/tokenize.h src/settings.h src/errorlogger.h src/token.h src/checkclass.h src/check.h test/testsuite.h
$(CXX) $(CXXFLAGS) -c -o test/testunusedprivfunc.o test/testunusedprivfunc.cpp

View File

@ -18,7 +18,7 @@
//---------------------------------------------------------------------------
#include "checkfunctionusage.h"
#include "checkunusedfunctions.h"
#include "tokenize.h"
//---------------------------------------------------------------------------
@ -29,22 +29,22 @@
// FUNCTION USAGE - Check for unused functions etc
//---------------------------------------------------------------------------
CheckFunctionUsage::CheckFunctionUsage(ErrorLogger *errorLogger)
CheckUnusedFunctions::CheckUnusedFunctions(ErrorLogger *errorLogger)
{
_errorLogger = errorLogger;
}
CheckFunctionUsage::~CheckFunctionUsage()
CheckUnusedFunctions::~CheckUnusedFunctions()
{
}
void CheckFunctionUsage::setErrorLogger(ErrorLogger *errorLogger)
void CheckUnusedFunctions::setErrorLogger(ErrorLogger *errorLogger)
{
_errorLogger = errorLogger;
}
void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
{
// Function declarations..
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
@ -147,7 +147,7 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
void CheckFunctionUsage::check()
void CheckUnusedFunctions::check()
{
for (std::map<std::string, FunctionUsage>::const_iterator it = _functions.begin(); it != _functions.end(); ++it)
{

View File

@ -18,18 +18,18 @@
//---------------------------------------------------------------------------
#ifndef CheckFunctionUsageH
#define CheckFunctionUsageH
#ifndef checkunusedfunctionsH
#define checkunusedfunctionsH
//---------------------------------------------------------------------------
#include "tokenize.h"
#include "errorlogger.h"
class CheckFunctionUsage
class CheckUnusedFunctions
{
public:
CheckFunctionUsage(ErrorLogger *errorLogger = 0);
~CheckFunctionUsage();
CheckUnusedFunctions(ErrorLogger *errorLogger = 0);
~CheckUnusedFunctions();
/**
* Errors found by this class are forwarded to the given

View File

@ -20,7 +20,6 @@
#include "preprocessor.h" // preprocessor.
#include "tokenize.h" // <- Tokenizer
#include "checkfunctionusage.h"
#include "filelister.h"
#include "check.h"
@ -297,7 +296,7 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
unsigned int CppCheck::check()
{
_checkFunctionUsage.setErrorLogger(this);
_checkUnusedFunctions.setErrorLogger(this);
std::sort(_filenames.begin(), _filenames.end());
for (unsigned int c = 0; c < _filenames.size(); c++)
{
@ -367,7 +366,7 @@ unsigned int CppCheck::check()
if (_settings._errorsOnly == false)
_errorLogger->reportOut("Checking usage of global functions..");
_checkFunctionUsage.check();
_checkUnusedFunctions.check();
}
@ -410,7 +409,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
_tokenizer.simplifyTokenList();
if (_settings._unusedFunctions)
_checkFunctionUsage.parseTokens(_tokenizer);
_checkUnusedFunctions.parseTokens(_tokenizer);
// call all "runSimplifiedChecks" in all registered Check classes
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)

View File

@ -26,7 +26,7 @@
#include <map>
#include "settings.h"
#include "errorlogger.h"
#include "checkfunctionusage.h"
#include "checkunusedfunctions.h"
/**
* This is the base class which will use other classes to do
@ -135,7 +135,7 @@ private:
std::vector<std::string> _filenames;
/** Key is file name, and value is the content of the file */
std::map<std::string, std::string> _fileContents;
CheckFunctionUsage _checkFunctionUsage;
CheckUnusedFunctions _checkUnusedFunctions;
ErrorLogger *_errorLogger;
/** Current configuration */

View File

@ -19,15 +19,15 @@
#include "../src/tokenize.h"
#include "testsuite.h"
#include "../src/checkfunctionusage.h"
#include "../src/checkunusedfunctions.h"
#include <sstream>
extern std::ostringstream errout;
class TestFunctionUsage : public TestFixture
class TestUnusedFunctions : public TestFixture
{
public:
TestFunctionUsage() : TestFixture("TestFunctionUsage")
TestUnusedFunctions() : TestFixture("TestUnusedFunctions")
{ }
private:
@ -54,9 +54,9 @@ private:
errout.str("");
// Check for unused functions..
CheckFunctionUsage checkFunctionUsage(this);
checkFunctionUsage.parseTokens(tokenizer);
checkFunctionUsage.check();
CheckUnusedFunctions checkUnusedFunctions(this);
checkUnusedFunctions.parseTokens(tokenizer);
checkUnusedFunctions.check();
}
void incondition()
@ -121,5 +121,5 @@ private:
}
};
REGISTER_TEST(TestFunctionUsage)
REGISTER_TEST(TestUnusedFunctions)