Skip to content
Open
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
4 changes: 2 additions & 2 deletions lib/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class CPPCHECKLIB Check {
Check& operator=(const Check &) = delete;

/** run checks, the token list is not simplified */
virtual void runChecks(const Tokenizer &, ErrorLogger *) = 0;
virtual void runChecks(const Tokenizer &, ErrorLogger&) = 0;

/** get error messages */
virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const = 0;
virtual void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const = 0;

/** class name, used to generate documentation */
const std::string& name() const {
Expand Down
4 changes: 2 additions & 2 deletions lib/check64bit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ void Check64BitPortabilityImpl::returnIntegerError(const Token *tok)
"The safe way is to always return a pointer.", CWE758, Certainty::normal);
}

void Check64BitPortability::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void Check64BitPortability::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
Check64BitPortabilityImpl check64BitPortability(&tokenizer, tokenizer.getSettings(), errorLogger);
check64BitPortability.pointerassignment();
}

void Check64BitPortability::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void Check64BitPortability::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
Check64BitPortabilityImpl c(nullptr, settings, errorLogger);
c.assignmentAddressToIntegerError(nullptr);
Expand Down
6 changes: 3 additions & 3 deletions lib/check64bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class CPPCHECKLIB Check64BitPortability : public Check {

private:
/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "Check if there is 64-bit portability issues:\n"
Expand All @@ -63,7 +63,7 @@ class CPPCHECKLIB Check64BitPortability : public Check {
class CPPCHECKLIB Check64BitPortabilityImpl : public CheckImpl {
public:
/** This constructor is used when running checks. */
Check64BitPortabilityImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
Check64BitPortabilityImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

/** Check for pointer assignment */
Expand Down
4 changes: 2 additions & 2 deletions lib/checkassert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ bool CheckAssertImpl::inSameScope(const Token* returnTok, const Token* assignTok
return returnTok->scope() == assignTok->scope();
}

void CheckAssert::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckAssert::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckAssertImpl checkAssert(&tokenizer, tokenizer.getSettings(), errorLogger);
checkAssert.assertWithSideEffects();
}

void CheckAssert::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckAssert::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckAssertImpl c(nullptr, settings, errorLogger);
c.sideEffectInAssertError(nullptr, "function");
Expand Down
6 changes: 3 additions & 3 deletions lib/checkassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class CPPCHECKLIB CheckAssert : public Check {

private:
/** run checks, the token list is not simplified */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "Warn if there are side effects in assert statements (since this cause different behaviour in debug/release builds).\n";
Expand All @@ -57,7 +57,7 @@ class CPPCHECKLIB CheckAssert : public Check {

class CPPCHECKLIB CheckAssertImpl : public CheckImpl {
public:
CheckAssertImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckAssertImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

void assertWithSideEffects();
Expand Down
4 changes: 2 additions & 2 deletions lib/checkautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,15 @@ void CheckAutoVariablesImpl::errorInvalidDeallocation(const Token *tok, const Va
"that has been allocated dynamically.", CWE590, Certainty::normal);
}

void CheckAutoVariables::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckAutoVariables::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckAutoVariablesImpl checkAutoVariables(&tokenizer, tokenizer.getSettings(), errorLogger);
checkAutoVariables.assignFunctionArg();
checkAutoVariables.autoVariables();
checkAutoVariables.checkVarLifetime();
}

void CheckAutoVariables::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckAutoVariables::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckAutoVariablesImpl c(nullptr,settings,errorLogger);
c.errorAutoVariableAssignment(nullptr, false);
Expand Down
6 changes: 3 additions & 3 deletions lib/checkautovariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class CPPCHECKLIB CheckAutoVariables : public Check {

private:
/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "A pointer to a variable is only valid as long as the variable is in scope.\n"
Expand All @@ -72,7 +72,7 @@ class CPPCHECKLIB CheckAutoVariablesImpl : public CheckImpl
{
public:
/** This constructor is used when running checks. */
CheckAutoVariablesImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckAutoVariablesImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

/** assign function argument */
Expand Down
4 changes: 2 additions & 2 deletions lib/checkbool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ void CheckBoolImpl::returnValueBoolError(const Token *tok)
reportError(tok, Severity::style, "returnNonBoolInBooleanFunction", "Non-boolean value returned from function returning bool");
}

void CheckBool::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckBool::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckBoolImpl checkBool(&tokenizer, tokenizer.getSettings(), errorLogger);

Expand All @@ -529,7 +529,7 @@ void CheckBool::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
checkBool.checkBitwiseOnBoolean();
}

void CheckBool::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckBool::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckBoolImpl c(nullptr, settings, errorLogger);
c.assignBoolToPointerError(nullptr);
Expand Down
6 changes: 3 additions & 3 deletions lib/checkbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class CPPCHECKLIB CheckBool : public Check {

private:
/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "Boolean type checks\n"
Expand All @@ -67,7 +67,7 @@ class CPPCHECKLIB CheckBoolImpl : public CheckImpl
{
public:
/** @brief This constructor is used when running checks. */
CheckBoolImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckBoolImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

/** @brief %Check for comparison of function returning bool*/
Expand Down
6 changes: 3 additions & 3 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ Check::FileInfo * CheckBufferOverrun::loadFileInfoFromXml(const tinyxml2::XMLEle
/** @brief Analyse all file infos for all TU */
bool CheckBufferOverrun::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger)
{
CheckBufferOverrunImpl dummy(nullptr, settings, &errorLogger);
CheckBufferOverrunImpl dummy(nullptr, settings, errorLogger);
dummy.
logChecker("CheckBufferOverrun::analyseWholeProgram");

Expand Down Expand Up @@ -1214,7 +1214,7 @@ void CheckBufferOverrunImpl::negativeMemoryAllocationSizeError(const Token* tok,
msg, CWE131, inconclusive ? Certainty::inconclusive : Certainty::normal);
}

void CheckBufferOverrun::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckBufferOverrun::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckBufferOverrunImpl checkBufferOverrun(&tokenizer, tokenizer.getSettings(), errorLogger);
checkBufferOverrun.arrayIndex();
Expand All @@ -1227,7 +1227,7 @@ void CheckBufferOverrun::runChecks(const Tokenizer &tokenizer, ErrorLogger *erro
checkBufferOverrun.negativeArraySize();
}

void CheckBufferOverrun::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckBufferOverrun::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckBufferOverrunImpl c(nullptr, settings, errorLogger);
c.arrayIndexError(nullptr, std::vector<Dimension>(), std::vector<ValueFlow::Value>());
Expand Down
6 changes: 3 additions & 3 deletions lib/checkbufferoverrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ class CPPCHECKLIB CheckBufferOverrun : public Check {
CheckBufferOverrun() : Check("Bounds checking") {}

private:
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

/** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer &tokenizer, const Settings &settings, const std::string& /*currentConfig*/) const override;

/** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override;

Expand All @@ -96,7 +96,7 @@ class CPPCHECKLIB CheckBufferOverrunImpl : public CheckImpl
{
public:
/** This constructor is used when running checks. */
CheckBufferOverrunImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckBufferOverrunImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

void arrayIndex();
Expand Down
8 changes: 4 additions & 4 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static bool isVclTypeInit(const Type *type)
}
//---------------------------------------------------------------------------

CheckClassImpl::CheckClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckClassImpl::CheckClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger),
mSymbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
{}
Expand Down Expand Up @@ -3833,7 +3833,7 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<C
(void)ctu;
(void)settings;

CheckClassImpl dummy(nullptr, settings, &errorLogger);
CheckClassImpl dummy(nullptr, settings, errorLogger);
dummy.
logChecker("CheckClass::analyseWholeProgram");

Expand Down Expand Up @@ -3882,7 +3882,7 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<C
return foundErrors;
}

void CheckClass::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckClass::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
if (tokenizer.isC())
return;
Expand Down Expand Up @@ -3913,7 +3913,7 @@ void CheckClass::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
checkClass.checkUnsafeClassRefMember();
}

void CheckClass::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckClass::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckClassImpl c(nullptr, settings, errorLogger);
c.noConstructorError(nullptr, "classname", false);
Expand Down
6 changes: 3 additions & 3 deletions lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CPPCHECKLIB CheckClass : public Check {
CheckClass() : Check("Class") {}

/** @brief Run checks on the normal token list */
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

/** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer &tokenizer, const Settings& /*settings*/, const std::string& currentConfig) const override;
Expand All @@ -68,7 +68,7 @@ class CPPCHECKLIB CheckClass : public Check {
/** @brief Analyse all file infos for all TU */
bool analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<Check::FileInfo*> &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "Check the code for each class.\n"
Expand Down Expand Up @@ -100,7 +100,7 @@ class CPPCHECKLIB CheckClass : public Check {
class CPPCHECKLIB CheckClassImpl : public CheckImpl {
public:
/** This constructor is used when running checks. */
CheckClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger);
CheckClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger);

/** @brief Set of the STL types whose operator[] is not const */
static const std::set<std::string> stl_containers_not_const;
Expand Down
4 changes: 2 additions & 2 deletions lib/checkcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ void CheckConditionImpl::compareValueOutOfTypeRangeError(const Token *comparison
Certainty::normal);
}

void CheckCondition::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckCondition::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckConditionImpl checkCondition(&tokenizer, tokenizer.getSettings(), errorLogger);
checkCondition.multiCondition();
Expand All @@ -2115,7 +2115,7 @@ void CheckCondition::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog
checkCondition.alwaysTrueFalse();
}

void CheckCondition::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckCondition::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckConditionImpl c(nullptr, settings, errorLogger);

Expand Down
6 changes: 3 additions & 3 deletions lib/checkcondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class CPPCHECKLIB CheckCondition : public Check {
CheckCondition() : Check("Condition") {}

private:
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

std::string classInfo() const override {
return "Match conditions with assignments and other conditions:\n"
Expand All @@ -81,7 +81,7 @@ class CPPCHECKLIB CheckCondition : public Check {
class CPPCHECKLIB CheckConditionImpl : public CheckImpl {
public:
/** This constructor is used when running checks. */
CheckConditionImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckConditionImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

/** mismatching assignment / comparison */
Expand Down
4 changes: 2 additions & 2 deletions lib/checkexceptionsafety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void CheckExceptionSafetyImpl::rethrowNoCurrentExceptionError(const Token *tok)
CWE480, Certainty::normal);
}

void CheckExceptionSafety::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckExceptionSafety::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
if (tokenizer.isC())
return;
Expand All @@ -424,7 +424,7 @@ void CheckExceptionSafety::runChecks(const Tokenizer &tokenizer, ErrorLogger *er
checkExceptionSafety.rethrowNoCurrentException();
}

void CheckExceptionSafety::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckExceptionSafety::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckExceptionSafetyImpl c(nullptr, settings, errorLogger);
c.destructorsError(nullptr, "Class");
Expand Down
6 changes: 3 additions & 3 deletions lib/checkexceptionsafety.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
CheckExceptionSafety() : Check("Exception Safety") {}

private:
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
void runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger) override;

/** Generate all possible errors (for --errorlist) */
void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override;
void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override;

/** wiki formatted description of the class (for --doc) */
std::string classInfo() const override {
Expand All @@ -71,7 +71,7 @@ class CPPCHECKLIB CheckExceptionSafety : public Check {
class CPPCHECKLIB CheckExceptionSafetyImpl : public CheckImpl {
public:
/** This constructor is used when running checks. */
CheckExceptionSafetyImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger)
CheckExceptionSafetyImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger)
: CheckImpl(tokenizer, settings, errorLogger) {}

/** Don't throw exceptions in destructors */
Expand Down
4 changes: 2 additions & 2 deletions lib/checkfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ void CheckFunctionsImpl::useStandardLibraryError(const Token *tok, const std::st
"Consider using " + expected + " instead of loop.");
}

void CheckFunctions::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger)
void CheckFunctions::runChecks(const Tokenizer &tokenizer, ErrorLogger& errorLogger)
{
CheckFunctionsImpl checkFunctions(&tokenizer, tokenizer.getSettings(), errorLogger);

Expand All @@ -872,7 +872,7 @@ void CheckFunctions::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog
checkFunctions.useStandardLibrary();
}

void CheckFunctions::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const
void CheckFunctions::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const
{
CheckFunctionsImpl c(nullptr, settings, errorLogger);

Expand Down
Loading
Loading