Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

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

Check::Check(const std::string &aname)
: mTokenizer(nullptr), mSettings(nullptr), mErrorLogger(nullptr), mName(aname)
Check::Check()
: mTokenizer(nullptr), mSettings(nullptr), mErrorLogger(nullptr)
{
auto it = std::find_if(instances().begin(), instances().end(), [&](const Check* i) {
return i->name() > aname;
return i->name() > name();
});
if (it == instances().end())
instances().push_back(this);
Expand Down
13 changes: 4 additions & 9 deletions lib/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class Tokenizer;
class CPPCHECKLIB Check {
public:
/** This constructor is used when registering the CheckClass */
explicit Check(const std::string &aname);
explicit Check();

/** This constructor is used when running checks. */
Check(std::string aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger), mName(std::move(aname)) {}
Check(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger) {}

virtual ~Check() {
if (!mTokenizer)
Expand All @@ -83,9 +83,7 @@ class CPPCHECKLIB Check {
virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const = 0;

/** class name, used to generate documentation */
const std::string& name() const {
return mName;
}
virtual std::string name() const = 0;

/** get information about this class, used to generate documentation */
virtual std::string classInfo() const = 0;
Expand Down Expand Up @@ -162,9 +160,6 @@ class CPPCHECKLIB Check {
* will call this method
*/
bool wrongData(const Token *tok, const char *str);

private:
const std::string mName;
};

/// @}
Expand Down
6 changes: 3 additions & 3 deletions lib/check64bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class Tokenizer;
class CPPCHECKLIB Check64BitPortability : public Check {
public:
/** This constructor is used when registering the Check64BitPortability */
Check64BitPortability() : Check(myName()) {}
Check64BitPortability() : Check() {}

/** This constructor is used when running checks. */
Check64BitPortability(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand All @@ -73,7 +73,7 @@ class CPPCHECKLIB Check64BitPortability : public Check {
c.returnPointerError(nullptr);
}

static std::string myName() {
std::string name() const override {
return "64-bit portability";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class Tokenizer;

class CPPCHECKLIB CheckAssert : public Check {
public:
CheckAssert() : Check(myName()) {}
CheckAssert() : Check() {}

CheckAssert(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** run checks, the token list is not simplified */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand All @@ -69,7 +69,7 @@ class CPPCHECKLIB CheckAssert : public Check {
c.assignmentInAssertError(nullptr, "var");
}

static std::string myName() {
std::string name() const override {
return "Assert";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkautovariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace ValueFlow {
class CPPCHECKLIB CheckAutoVariables : public Check {
public:
/** This constructor is used when registering the CheckClass */
CheckAutoVariables() : Check(myName()) {}
CheckAutoVariables() : Check() {}

/** This constructor is used when running checks. */
CheckAutoVariables(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand Down Expand Up @@ -107,7 +107,7 @@ class CPPCHECKLIB CheckAutoVariables : public Check {
c.errorDanglingTemporaryLifetime(nullptr, nullptr, nullptr);
}

static std::string myName() {
std::string name() const override {
return "Auto Variables";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class Tokenizer;
class CPPCHECKLIB CheckBool : public Check {
public:
/** @brief This constructor is used when registering the CheckClass */
CheckBool() : Check(myName()) {}
CheckBool() : Check() {}

/** @brief This constructor is used when running checks. */
CheckBool(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand Down Expand Up @@ -124,7 +124,7 @@ class CPPCHECKLIB CheckBool : public Check {
c.returnValueBoolError(nullptr);
}

static std::string myName() {
std::string name() const override {
return "Boolean";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkboost.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class Token;
class CPPCHECKLIB CheckBoost : public Check {
public:
/** This constructor is used when registering the CheckClass */
CheckBoost() : Check(myName()) {}
CheckBoost() : Check() {}

/** This constructor is used when running checks. */
CheckBoost(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand All @@ -66,7 +66,7 @@ class CPPCHECKLIB CheckBoost : public Check {
c.boostForeachError(nullptr);
}

static std::string myName() {
std::string name() const override {
return "Boost usage";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkbufferoverrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
public:

/** This constructor is used when registering the CheckClass */
CheckBufferOverrun() : Check(myName()) {}
CheckBufferOverrun() : Check() {}

/** This constructor is used when running checks. */
CheckBufferOverrun(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
CheckBufferOverrun checkBufferOverrun(tokenizer, settings, errorLogger);
Expand Down Expand Up @@ -154,7 +154,7 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
static bool analyseWholeProgram1(const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> &callsMap, const CTU::FileInfo::UnsafeUsage &unsafeUsage, int type, ErrorLogger &errorLogger);


static std::string myName() {
std::string name() const override {
return "Bounds checking";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static bool isVclTypeInit(const Type *type)
//---------------------------------------------------------------------------

CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger),
: Check(tokenizer, settings, errorLogger),
mSymbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
{}

Expand Down
4 changes: 2 additions & 2 deletions lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace tinyxml2 {
class CPPCHECKLIB CheckClass : public Check {
public:
/** @brief This constructor is used when registering the CheckClass */
CheckClass() : Check(myName()), mSymbolDatabase(nullptr) {}
CheckClass() : Check(), mSymbolDatabase(nullptr) {}

/** @brief This constructor is used when running checks. */
CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger);
Expand Down Expand Up @@ -272,7 +272,7 @@ class CPPCHECKLIB CheckClass : public Check {
c.unsafeClassRefMemberError(nullptr, "UnsafeClass::var");
}

static std::string myName() {
std::string name() const override {
return "Class";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkcondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ namespace ValueFlow {
class CPPCHECKLIB CheckCondition : public Check {
public:
/** This constructor is used when registering the CheckAssignIf */
CheckCondition() : Check(myName()) {}
CheckCondition() : Check() {}

/** This constructor is used when running checks. */
CheckCondition(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
CheckCondition checkCondition(tokenizer, settings, errorLogger);
Expand Down Expand Up @@ -198,7 +198,7 @@ class CPPCHECKLIB CheckCondition : public Check {
c.compareValueOutOfTypeRangeError(nullptr, "unsigned char", 256, true);
}

static std::string myName() {
std::string name() const override {
return "Condition";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkexceptionsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ static const struct CWE CWE480(480U); // Use of Incorrect Operator
class CPPCHECKLIB CheckExceptionSafety : public Check {
public:
/** This constructor is used when registering the CheckClass */
CheckExceptionSafety() : Check(myName()) {}
CheckExceptionSafety() : Check() {}

/** This constructor is used when running checks. */
CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
if (tokenizer->isC())
Expand Down Expand Up @@ -119,7 +119,7 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
}

/** Short description of class (for --doc) */
static std::string myName() {
std::string name() const override {
return "Exception Safety";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ namespace ValueFlow {
class CPPCHECKLIB CheckFunctions : public Check {
public:
/** This constructor is used when registering the CheckFunctions */
CheckFunctions() : Check(myName()) {}
CheckFunctions() : Check() {}

/** This constructor is used when running checks. */
CheckFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand Down Expand Up @@ -148,7 +148,7 @@ class CPPCHECKLIB CheckFunctions : public Check {
c.useStandardLibraryError(nullptr, "memcpy");
}

static std::string myName() {
std::string name() const override {
return "Check function usage";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class Tokenizer;
class CPPCHECKLIB CheckInternal : public Check {
public:
/** This constructor is used when registering the CheckClass */
CheckInternal() : Check(myName()) {}
CheckInternal() : Check() {}

/** This constructor is used when running checks. */
CheckInternal(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
if (!settings->checks.isEnabled(Checks::internalCheck))
Expand Down Expand Up @@ -106,7 +106,7 @@ class CPPCHECKLIB CheckInternal : public Check {
c.checkRedundantTokCheckError(nullptr);
}

static std::string myName() {
std::string name() const override {
return "cppcheck internal API usage";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class ErrorLogger;
class CPPCHECKLIB CheckIO : public Check {
public:
/** @brief This constructor is used when registering CheckIO */
CheckIO() : Check(myName()) {}
CheckIO() : Check() {}

/** @brief This constructor is used when running checks. */
CheckIO(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

/** @brief Run checks on the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
Expand Down Expand Up @@ -159,7 +159,7 @@ class CPPCHECKLIB CheckIO : public Check {
c.wrongPrintfScanfPosixParameterPositionError(nullptr, "printf", 2, 1);
}

static std::string myName() {
std::string name() const override {
return "IO using format string";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkleakautovar.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ class CPPCHECKLIB VarInfo {
class CPPCHECKLIB CheckLeakAutoVar : public Check {
public:
/** This constructor is used when registering the CheckLeakAutoVar */
CheckLeakAutoVar() : Check(myName()) {}
CheckLeakAutoVar() : Check() {}

/** This constructor is used when running checks. */
CheckLeakAutoVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) {}
: Check(tokenizer, settings, errorLogger) {}

void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) override {
CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger);
Expand Down Expand Up @@ -168,7 +168,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check {
c.doubleFreeError(nullptr, nullptr, "varname", 0);
}

static std::string myName() {
std::string name() const override {
return "Leaks (auto variables)";
}

Expand Down
Loading