Skip to content

Commit

Permalink
CheckUnusedFunctions: moved instance into source file
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 2, 2023
1 parent 18191fb commit 2ae63b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 9 additions & 3 deletions lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ namespace CTU {

//---------------------------------------------------------------------------



// Register this check class
CheckUnusedFunctions CheckUnusedFunctions::instance;
namespace {
CheckUnusedFunctions instance;
}

static const struct CWE CWE561(561U); // Dead Code

Expand All @@ -68,6 +68,12 @@ static std::string stripTemplateParameters(const std::string& funcName) {
// FUNCTION USAGE - Check for unused functions etc
//---------------------------------------------------------------------------

void CheckUnusedFunctions::clear()
{
instance.mFunctions.clear();
instance.mFunctionCalls.clear();
}

void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char FileName[], const Settings *settings)
{
const bool doMarkup = settings->library.markupFile(FileName);
Expand Down
7 changes: 1 addition & 6 deletions lib/checkunusedfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check {
CheckUnusedFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}

static void clear() {
instance.mFunctions.clear();
instance.mFunctionCalls.clear();
}
static void clear();

// Parse current tokens and determine..
// * Check what functions are used
Expand All @@ -79,8 +76,6 @@ class CPPCHECKLIB CheckUnusedFunctions : public Check {
static void analyseWholeProgram(const Settings &settings, ErrorLogger * const errorLogger, const std::string &buildDir);

private:
static CheckUnusedFunctions instance;

void getErrorMessages(ErrorLogger *errorLogger, const Settings * /*settings*/) const override {
CheckUnusedFunctions::unusedFunctionError(errorLogger, emptyString, 0, "funcName");
}
Expand Down

0 comments on commit 2ae63b0

Please sign in to comment.