From 169286e07b2e521f17931a80ed5d2a6c76600dc9 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 31 May 2026 17:24:20 +0200 Subject: [PATCH 1/3] pass `ErrorLogger` by reference into `Check::getErrorMessages()` --- lib/check.h | 2 +- lib/check64bit.cpp | 4 ++-- lib/check64bit.h | 2 +- lib/checkassert.cpp | 4 ++-- lib/checkassert.h | 2 +- lib/checkautovariables.cpp | 4 ++-- lib/checkautovariables.h | 2 +- lib/checkbool.cpp | 4 ++-- lib/checkbool.h | 2 +- lib/checkbufferoverrun.cpp | 4 ++-- lib/checkbufferoverrun.h | 2 +- lib/checkclass.cpp | 4 ++-- lib/checkclass.h | 2 +- lib/checkcondition.cpp | 4 ++-- lib/checkcondition.h | 2 +- lib/checkexceptionsafety.cpp | 4 ++-- lib/checkexceptionsafety.h | 2 +- lib/checkfunctions.cpp | 4 ++-- lib/checkfunctions.h | 2 +- lib/checkinternal.cpp | 4 ++-- lib/checkinternal.h | 2 +- lib/checkio.cpp | 4 ++-- lib/checkio.h | 2 +- lib/checkleakautovar.cpp | 4 ++-- lib/checkleakautovar.h | 2 +- lib/checkmemoryleak.cpp | 16 ++++++++-------- lib/checkmemoryleak.h | 8 ++++---- lib/checknullpointer.cpp | 4 ++-- lib/checknullpointer.h | 2 +- lib/checkother.cpp | 4 ++-- lib/checkother.h | 2 +- lib/checkpostfixoperator.cpp | 4 ++-- lib/checkpostfixoperator.h | 2 +- lib/checksizeof.cpp | 4 ++-- lib/checksizeof.h | 2 +- lib/checkstl.cpp | 4 ++-- lib/checkstl.h | 2 +- lib/checkstring.cpp | 4 ++-- lib/checkstring.h | 2 +- lib/checktype.cpp | 4 ++-- lib/checktype.h | 2 +- lib/checkuninitvar.cpp | 4 ++-- lib/checkuninitvar.h | 2 +- lib/checkunusedvar.cpp | 4 ++-- lib/checkunusedvar.h | 2 +- lib/checkvaarg.cpp | 4 ++-- lib/checkvaarg.h | 2 +- lib/cppcheck.cpp | 2 +- test/testbufferoverrun.cpp | 2 +- 49 files changed, 81 insertions(+), 81 deletions(-) diff --git a/lib/check.h b/lib/check.h index 7deab9e52e7..2981cfb86cf 100644 --- a/lib/check.h +++ b/lib/check.h @@ -65,7 +65,7 @@ class CPPCHECKLIB Check { 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 { diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index 6c45c68aaeb..aad9cc6be91 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -189,9 +189,9 @@ void Check64BitPortability::runChecks(const Tokenizer &tokenizer, ErrorLogger *e 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); + Check64BitPortabilityImpl c(nullptr, settings, &errorLogger); c.assignmentAddressToIntegerError(nullptr); c.assignmentIntegerToAddressError(nullptr); c.returnIntegerError(nullptr); diff --git a/lib/check64bit.h b/lib/check64bit.h index bafb5646aaa..77e6fe871e8 100644 --- a/lib/check64bit.h +++ b/lib/check64bit.h @@ -51,7 +51,7 @@ class CPPCHECKLIB Check64BitPortability : public Check { /** @brief Run checks against the normal token list */ 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" diff --git a/lib/checkassert.cpp b/lib/checkassert.cpp index 8240304d83f..f939ccff866 100644 --- a/lib/checkassert.cpp +++ b/lib/checkassert.cpp @@ -184,9 +184,9 @@ void CheckAssert::runChecks(const Tokenizer &tokenizer, ErrorLogger *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); + CheckAssertImpl c(nullptr, settings, &errorLogger); c.sideEffectInAssertError(nullptr, "function"); c.assignmentInAssertError(nullptr, "var"); } diff --git a/lib/checkassert.h b/lib/checkassert.h index f6190bb8d25..2bb9ddb7ac1 100644 --- a/lib/checkassert.h +++ b/lib/checkassert.h @@ -48,7 +48,7 @@ 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 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"; diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 48ca74253a5..89203728bbe 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -825,9 +825,9 @@ void CheckAutoVariables::runChecks(const Tokenizer &tokenizer, ErrorLogger *erro 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); + CheckAutoVariablesImpl c(nullptr,settings,&errorLogger); c.errorAutoVariableAssignment(nullptr, false); c.errorReturnReference(nullptr, ErrorPath{}, false); c.errorDanglingReference(nullptr, nullptr, ErrorPath{}); diff --git a/lib/checkautovariables.h b/lib/checkautovariables.h index 4bdbfc4c730..cc800135fa9 100644 --- a/lib/checkautovariables.h +++ b/lib/checkautovariables.h @@ -54,7 +54,7 @@ class CPPCHECKLIB CheckAutoVariables : public Check { /** @brief Run checks against the normal token list */ 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" diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 0d7516a9418..5610d11ac63 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -529,9 +529,9 @@ 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); + CheckBoolImpl c(nullptr, settings, &errorLogger); c.assignBoolToPointerError(nullptr); c.assignBoolToFloatError(nullptr); c.comparisonOfFuncReturningBoolError(nullptr, "func_name"); diff --git a/lib/checkbool.h b/lib/checkbool.h index 5eafc4d692d..3b5c943e2c6 100644 --- a/lib/checkbool.h +++ b/lib/checkbool.h @@ -48,7 +48,7 @@ class CPPCHECKLIB CheckBool : public Check { /** @brief Run checks against the normal token list */ 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" diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 7f0612963b9..058d6c8557b 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1227,9 +1227,9 @@ 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); + CheckBufferOverrunImpl c(nullptr, settings, &errorLogger); c.arrayIndexError(nullptr, std::vector(), std::vector()); c.pointerArithmeticError(nullptr, nullptr, nullptr); c.negativeIndexError(nullptr, std::vector(), std::vector()); diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index b71f4520d48..62c6f9f54fd 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -72,7 +72,7 @@ class CPPCHECKLIB CheckBufferOverrun : public Check { /** @brief Analyse all file infos for all TU */ bool analyseWholeProgram(const CTU::FileInfo &ctu, const std::list &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; diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index d7eb9b43b35..10915d8317b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3913,9 +3913,9 @@ 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); + CheckClassImpl c(nullptr, settings, &errorLogger); c.noConstructorError(nullptr, "classname", false); c.noExplicitConstructorError(nullptr, "classname", false); //c.copyConstructorMallocError(nullptr, 0, "var"); diff --git a/lib/checkclass.h b/lib/checkclass.h index ccf154b645d..2ad3580d989 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -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 &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" diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 365a677b5cb..2ae25832de4 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -2115,9 +2115,9 @@ 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); + CheckConditionImpl c(nullptr, settings, &errorLogger); c.assignIfError(nullptr, nullptr, "", false); c.badBitmaskCheckError(nullptr); diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 56d2c6f25e0..9dd04b3375f 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -56,7 +56,7 @@ class CPPCHECKLIB CheckCondition : public Check { private: 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" diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index b0c510ed80a..80893fe6d48 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -424,9 +424,9 @@ 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); + CheckExceptionSafetyImpl c(nullptr, settings, &errorLogger); c.destructorsError(nullptr, "Class"); c.deallocThrowError(nullptr, "p"); c.rethrowCopyError(nullptr, "varname"); diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index 7de91ba812c..93457827471 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -53,7 +53,7 @@ class CPPCHECKLIB CheckExceptionSafety : public Check { 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 { diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index db50846b262..a7cfbc9e242 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -872,9 +872,9 @@ 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); + CheckFunctionsImpl c(nullptr, settings, &errorLogger); for (auto i = settings.library.functionwarn().cbegin(); i != settings.library.functionwarn().cend(); ++i) { c.functionCalledError(nullptr, Severity::style, i->first, i->second.message); diff --git a/lib/checkfunctions.h b/lib/checkfunctions.h index 42281774482..a0847276859 100644 --- a/lib/checkfunctions.h +++ b/lib/checkfunctions.h @@ -54,7 +54,7 @@ class CPPCHECKLIB CheckFunctions : public Check { /** @brief Run checks against the normal token list */ 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 function usage:\n" diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index 727df306e63..97a35c94953 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -393,9 +393,9 @@ void CheckInternal::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogg checkInternal.checkRedundantTokCheck(); } -void CheckInternal::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckInternal::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckInternalImpl c(nullptr, settings, errorLogger); + CheckInternalImpl c(nullptr, settings, &errorLogger); c.simplePatternError(nullptr, "class {", "Match"); c.complexPatternError(nullptr, "%type% ( )", "Match"); c.missingPercentCharacterError(nullptr, "%num", "Match"); diff --git a/lib/checkinternal.h b/lib/checkinternal.h index c1e5addc4da..5a87ff39054 100644 --- a/lib/checkinternal.h +++ b/lib/checkinternal.h @@ -48,7 +48,7 @@ class CPPCHECKLIB CheckInternal : public Check { private: 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 { // Don't include these checks on the WIKI where people can read what diff --git a/lib/checkio.cpp b/lib/checkio.cpp index a62955d3017..ed915274d1c 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -2060,9 +2060,9 @@ void CheckIO::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) checkIO.invalidScanf(); } -void CheckIO::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckIO::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckIOImpl c(nullptr, settings, errorLogger); + CheckIOImpl c(nullptr, settings, &errorLogger); c.coutCerrMisusageError(nullptr, "cout"); c.fflushOnInputStreamError(nullptr, "stdin"); c.ioWithoutPositioningError(nullptr); diff --git a/lib/checkio.h b/lib/checkio.h index e881e22cbf3..76e82cf56ea 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -52,7 +52,7 @@ class CPPCHECKLIB CheckIO : public Check { /** @brief Run checks on the normal token list */ 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 format string input/output operations.\n" diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 11d1086ee5d..2bbc30a9ca0 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -1284,9 +1284,9 @@ void CheckLeakAutoVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorL checkLeakAutoVar.check(); } -void CheckLeakAutoVar::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckLeakAutoVar::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckLeakAutoVarImpl c(nullptr, settings, errorLogger); + CheckLeakAutoVarImpl c(nullptr, settings, &errorLogger); c.deallocReturnError(nullptr, nullptr, "p"); c.configurationInfo(nullptr, { nullptr, VarInfo::USED }); // user configuration is needed to complete analysis c.doubleFreeError(nullptr, nullptr, "varname", 0); diff --git a/lib/checkleakautovar.h b/lib/checkleakautovar.h index 5d4fa07ec06..f9fa4c26626 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -113,7 +113,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check { private: 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 "Detect when a auto variable is allocated but not deallocated or deallocated twice.\n"; diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index d02bb607b33..2ff3d366a5b 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -496,9 +496,9 @@ void CheckMemoryLeakInFunction::runChecks(const Tokenizer &tokenizer, ErrorLogge checkMemoryLeak.checkReallocUsage(); } -void CheckMemoryLeakInFunction::getErrorMessages(ErrorLogger *e, const Settings &settings) const +void CheckMemoryLeakInFunction::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakInFunctionImpl c(nullptr, settings, e); + CheckMemoryLeakInFunctionImpl c(nullptr, settings, &e); c.memleakError(nullptr, "varname"); c.resourceLeakError(nullptr, "varname"); c.deallocuseError(nullptr, "varname"); @@ -700,9 +700,9 @@ void CheckMemoryLeakInClass::runChecks(const Tokenizer &tokenizer, ErrorLogger * checkMemoryLeak.check(); } -void CheckMemoryLeakInClass::getErrorMessages(ErrorLogger *e, const Settings &settings) const +void CheckMemoryLeakInClass::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakInClassImpl c(nullptr, settings, e); + CheckMemoryLeakInClassImpl c(nullptr, settings, &e); c.publicAllocationError(nullptr, "varname"); c.unsafeClassError(nullptr, "class", "class::varname"); } @@ -972,9 +972,9 @@ void CheckMemoryLeakStructMember::runChecks(const Tokenizer &tokenizer, ErrorLog checkMemoryLeak.check(); } -void CheckMemoryLeakStructMember::getErrorMessages(ErrorLogger * errorLogger, const Settings & settings) const +void CheckMemoryLeakStructMember::getErrorMessages(ErrorLogger& errorLogger, const Settings & settings) const { - (void)errorLogger; + (void)&errorLogger; (void)settings; } @@ -1224,9 +1224,9 @@ void CheckMemoryLeakNoVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *er checkMemoryLeak.check(); } -void CheckMemoryLeakNoVar::getErrorMessages(ErrorLogger *e, const Settings &settings) const +void CheckMemoryLeakNoVar::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakNoVarImpl c(nullptr, settings, e); + CheckMemoryLeakNoVarImpl c(nullptr, settings, &e); c.functionCallLeak(nullptr, "funcName", "funcName"); c.returnValueNotUsedError(nullptr, "funcName"); c.unsafeArgAllocError(nullptr, "funcName", "shared_ptr", "int"); diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index 4fa69742277..5377c7590ed 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -75,7 +75,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunction : public Check { void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override; /** Report all possible errors (for the --errorlist) */ - void getErrorMessages(ErrorLogger *e, const Settings &settings) const override; + void getErrorMessages(ErrorLogger& e, const Settings &settings) const override; /** * Get class information (--doc) @@ -100,7 +100,7 @@ class CPPCHECKLIB CheckMemoryLeakInClass : public Check { private: void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override; - void getErrorMessages(ErrorLogger *e, const Settings &settings) const override; + void getErrorMessages(ErrorLogger& e, const Settings &settings) const override; std::string classInfo() const override { return "If the constructor allocate memory then the destructor must deallocate it.\n"; @@ -120,7 +120,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : public Check { private: 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 "Don't forget to deallocate struct members\n"; @@ -140,7 +140,7 @@ class CPPCHECKLIB CheckMemoryLeakNoVar : public Check { private: void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override; - void getErrorMessages(ErrorLogger *e, const Settings &settings) const override; + void getErrorMessages(ErrorLogger& e, const Settings &settings) const override; std::string classInfo() const override { return "Not taking the address to allocated memory\n"; diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 92938b4a60f..ccca82ffd45 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -700,9 +700,9 @@ void CheckNullPointer::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorL checkNullPointer.nullConstantDereference(); } -void CheckNullPointer::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckNullPointer::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckNullPointerImpl c(nullptr, settings, errorLogger); + CheckNullPointerImpl c(nullptr, settings, &errorLogger); c.nullPointerError(nullptr, "pointer", nullptr, false); c.pointerArithmeticError(nullptr, nullptr, false); // TODO: nullPointerArithmeticOutOfMemory diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index 8e35fd7565a..e663d77e79f 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -67,7 +67,7 @@ class CPPCHECKLIB CheckNullPointer : public Check { bool analyseWholeProgram(const CTU::FileInfo &ctu, const std::list &fileInfo, const Settings& settings, ErrorLogger &errorLogger) override; /** Get error messages. Used by --errorlist */ - void getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const override; + void getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const override; /** class info in WIKI format. Used by --doc */ std::string classInfo() const override { diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 1adcaeb9c3a..faefe185de3 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -4839,9 +4839,9 @@ void CheckOther::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) checkOther.checkUnionZeroInit(); } -void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckOther::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckOtherImpl c(nullptr, settings, errorLogger); + CheckOtherImpl c(nullptr, settings, &errorLogger); // error c.zerodivError(nullptr, nullptr); diff --git a/lib/checkother.h b/lib/checkother.h index 97291b53769..3610de54963 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -62,7 +62,7 @@ class CPPCHECKLIB CheckOther : public Check { /** @brief Run checks against the normal token list */ 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 "Other checks\n" diff --git a/lib/checkpostfixoperator.cpp b/lib/checkpostfixoperator.cpp index 0d72b8e3860..87156ae5d2c 100644 --- a/lib/checkpostfixoperator.cpp +++ b/lib/checkpostfixoperator.cpp @@ -103,8 +103,8 @@ void CheckPostfixOperator::runChecks(const Tokenizer &tokenizer, ErrorLogger *er checkPostfixOperator.postfixOperator(); } -void CheckPostfixOperator::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckPostfixOperator::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckPostfixOperatorImpl c(nullptr, settings, errorLogger); + CheckPostfixOperatorImpl c(nullptr, settings, &errorLogger); c.postfixOperatorError(nullptr); } diff --git a/lib/checkpostfixoperator.h b/lib/checkpostfixoperator.h index de51a34fe42..407344f8fb9 100644 --- a/lib/checkpostfixoperator.h +++ b/lib/checkpostfixoperator.h @@ -50,7 +50,7 @@ class CPPCHECKLIB CheckPostfixOperator : public Check { private: 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 "Warn if using postfix operators ++ or -- rather than prefix operator\n"; } diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 694f73eeff6..3a24c39e845 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -513,9 +513,9 @@ void CheckSizeof::runChecks(const Tokenizer& tokenizer, ErrorLogger* errorLogger checkSizeof.sizeofVoid(); } -void CheckSizeof::getErrorMessages(ErrorLogger* errorLogger, const Settings& settings) const +void CheckSizeof::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckSizeofImpl c(nullptr, settings, errorLogger); + CheckSizeofImpl c(nullptr, settings, &errorLogger); c.sizeofForArrayParameterError(nullptr); c.sizeofForPointerError(nullptr, "varname"); c.divideBySizeofError(nullptr, "memset"); diff --git a/lib/checksizeof.h b/lib/checksizeof.h index 6fa7908eb92..6a51006ecfd 100644 --- a/lib/checksizeof.h +++ b/lib/checksizeof.h @@ -48,7 +48,7 @@ class CPPCHECKLIB CheckSizeof : public Check { /** @brief Run checks against the normal token list */ 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 "sizeof() usage checks\n" diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 08ac141610a..7183074c92c 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -3490,9 +3490,9 @@ void CheckStl::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) checkStl.size(); } -void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings& settings) const +void CheckStl::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckStlImpl c(nullptr, settings, errorLogger); + CheckStlImpl c(nullptr, settings, &errorLogger); c.outOfBoundsError(nullptr, "container", nullptr, "x", nullptr); c.invalidIteratorError(nullptr, "iterator"); c.iteratorsError(nullptr, "container1", "container2"); diff --git a/lib/checkstl.h b/lib/checkstl.h index b67632fbfed..1434ab1fdec 100644 --- a/lib/checkstl.h +++ b/lib/checkstl.h @@ -55,7 +55,7 @@ class CPPCHECKLIB CheckStl : public Check { /** 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 getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const override; std::string classInfo() const override { return "Check for invalid usage of STL:\n" diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index 00fa80998c1..488a4bc2cae 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -485,9 +485,9 @@ void CheckString::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger checkString.checkAlwaysTrueOrFalseStringCompare(); } -void CheckString::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckString::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckStringImpl c(nullptr, settings, errorLogger); + CheckStringImpl c(nullptr, settings, &errorLogger); c.stringLiteralWriteError(nullptr, nullptr); c.sprintfOverlappingDataError(nullptr, nullptr, "varname"); c.strPlusCharError(nullptr); diff --git a/lib/checkstring.h b/lib/checkstring.h index 2c19d64332c..cbb5272d083 100644 --- a/lib/checkstring.h +++ b/lib/checkstring.h @@ -48,7 +48,7 @@ class CPPCHECKLIB CheckString : public Check { /** @brief Run checks against the normal token list */ 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 "Detect misusage of C-style strings:\n" diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 262cb37a612..15b70c47151 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -542,9 +542,9 @@ void CheckType::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) checkType.checkFloatToIntegerOverflow(); } -void CheckType::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckType::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckTypeImpl c(nullptr, settings, errorLogger); + CheckTypeImpl c(nullptr, settings, &errorLogger); c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64)); c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31)); c.integerOverflowError(nullptr, ValueFlow::Value(1LL<<32)); diff --git a/lib/checktype.h b/lib/checktype.h index 8ebfb0fb5b2..c50a7238307 100644 --- a/lib/checktype.h +++ b/lib/checktype.h @@ -54,7 +54,7 @@ class CPPCHECKLIB CheckType : public Check { /** @brief Run checks against the normal token list */ 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 "Type checks\n" diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index bdfc07a8d47..dcc454288df 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1804,9 +1804,9 @@ void CheckUninitVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog checkUninitVar.check(); } -void CheckUninitVar::getErrorMessages(ErrorLogger* errorLogger, const Settings& settings) const +void CheckUninitVar::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckUninitVarImpl c(nullptr, settings, errorLogger); + CheckUninitVarImpl c(nullptr, settings, &errorLogger); ValueFlow::Value v{}; diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index f558fe84709..588cfa22fea 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -76,7 +76,7 @@ class CPPCHECKLIB CheckUninitVar : public Check { /** @brief Analyse all file infos for all TU */ bool analyseWholeProgram(const CTU::FileInfo &ctu, const std::list &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 "Uninitialized variables\n" diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index dd30f65db58..2cfe0a86c64 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1734,9 +1734,9 @@ void CheckUnusedVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog checkUnusedVar.checkFunctionVariableUsage(); } -void CheckUnusedVar::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckUnusedVar::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckUnusedVarImpl c(nullptr, settings, errorLogger); + CheckUnusedVarImpl c(nullptr, settings, &errorLogger); c.unusedVariableError(nullptr, "varname"); c.allocatedButUnusedVariableError(nullptr, "varname"); c.unreadVariableError(nullptr, "varname", false); diff --git a/lib/checkunusedvar.h b/lib/checkunusedvar.h index cddc36bb7e3..82c8f22cb04 100644 --- a/lib/checkunusedvar.h +++ b/lib/checkunusedvar.h @@ -53,7 +53,7 @@ class CPPCHECKLIB CheckUnusedVar : public Check { /** @brief Run checks against the normal token list */ 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 "UnusedVar checks\n" diff --git a/lib/checkvaarg.cpp b/lib/checkvaarg.cpp index 60a27b897b5..07e41ca395e 100644 --- a/lib/checkvaarg.cpp +++ b/lib/checkvaarg.cpp @@ -180,9 +180,9 @@ void CheckVaarg::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) check.va_list_usage(); } -void CheckVaarg::getErrorMessages(ErrorLogger *errorLogger, const Settings &settings) const +void CheckVaarg::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckVaargImpl c(nullptr, settings, errorLogger); + CheckVaargImpl c(nullptr, settings, &errorLogger); c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2"); c.referenceAs_va_start_error(nullptr, "arg1"); c.va_end_missingError(nullptr, "vl"); diff --git a/lib/checkvaarg.h b/lib/checkvaarg.h index 6d50bd94d0d..5e72443f916 100644 --- a/lib/checkvaarg.h +++ b/lib/checkvaarg.h @@ -47,7 +47,7 @@ class CPPCHECKLIB CheckVaarg : public Check { void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override; private: - 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 for misusage of variable argument lists:\n" diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 471a1a8ff1e..209e93d20b0 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1714,7 +1714,7 @@ void CppCheck::getErrorMessages(ErrorLogger &errorlogger) // call all "getErrorMessages" in all registered Check classes for (const Check * const c : CheckInstances::get()) - c->getErrorMessages(&errorlogger, s); + c->getErrorMessages(errorlogger, s); CheckUnusedFunctions::getErrorMessages(errorlogger); Preprocessor::getErrorMessages(errorlogger, s); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 29d8fa13d17..9dc62f11708 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -5171,7 +5171,7 @@ class TestBufferOverrun : public TestFixture { // Ticket #2292: segmentation fault when using --errorlist CheckBufferOverrun check; const Check& c = getCheck(check); - c.getErrorMessages(this, settingsDefault); + c.getErrorMessages(*this, settingsDefault); // we are not interested in the output - just consume it ignore_errout(); } From af763fdae115e3c047ab6489741b684059182a8d Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 31 May 2026 17:39:32 +0200 Subject: [PATCH 2/3] pass `ErrorLogger` by reference into `CheckImpl` --- lib/check64bit.cpp | 4 ++-- lib/check64bit.h | 2 +- lib/checkassert.cpp | 4 ++-- lib/checkassert.h | 2 +- lib/checkautovariables.cpp | 4 ++-- lib/checkautovariables.h | 2 +- lib/checkbool.cpp | 4 ++-- lib/checkbool.h | 2 +- lib/checkbufferoverrun.cpp | 6 ++--- lib/checkbufferoverrun.h | 2 +- lib/checkclass.cpp | 8 +++---- lib/checkclass.h | 2 +- lib/checkcondition.cpp | 4 ++-- lib/checkcondition.h | 2 +- lib/checkexceptionsafety.cpp | 4 ++-- lib/checkexceptionsafety.h | 2 +- lib/checkfunctions.cpp | 4 ++-- lib/checkfunctions.h | 2 +- lib/checkimpl.cpp | 9 ++------ lib/checkimpl.h | 4 ++-- lib/checkinternal.cpp | 4 ++-- lib/checkinternal.h | 2 +- lib/checkio.cpp | 4 ++-- lib/checkio.h | 2 +- lib/checkleakautovar.cpp | 4 ++-- lib/checkleakautovar.h | 2 +- lib/checkmemoryleak.cpp | 19 +++++++--------- lib/checkmemoryleak.h | 10 ++++----- lib/checknullpointer.cpp | 6 ++--- lib/checknullpointer.h | 2 +- lib/checkother.cpp | 4 ++-- lib/checkother.h | 2 +- lib/checkpostfixoperator.cpp | 4 ++-- lib/checkpostfixoperator.h | 2 +- lib/checksizeof.cpp | 4 ++-- lib/checksizeof.h | 2 +- lib/checkstl.cpp | 4 ++-- lib/checkstl.h | 2 +- lib/checkstring.cpp | 4 ++-- lib/checkstring.h | 2 +- lib/checktype.cpp | 4 ++-- lib/checktype.h | 2 +- lib/checkuninitvar.cpp | 6 ++--- lib/checkuninitvar.h | 2 +- lib/checkunusedvar.cpp | 4 ++-- lib/checkunusedvar.h | 2 +- lib/checkvaarg.cpp | 4 ++-- lib/checkvaarg.h | 2 +- test/test64bit.cpp | 2 +- test/testcharvar.cpp | 2 +- test/testclass.cpp | 38 ++++++++++++++++---------------- test/testconstructors.cpp | 2 +- test/testincompletestatement.cpp | 2 +- test/testio.cpp | 2 +- test/testmemleak.cpp | 12 +++++----- test/testother.cpp | 6 ++--- test/testpostfixoperator.cpp | 2 +- test/testuninitvar.cpp | 6 ++--- test/testunusedprivfunc.cpp | 2 +- test/testunusedvar.cpp | 8 +++---- 60 files changed, 130 insertions(+), 138 deletions(-) diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index aad9cc6be91..bae14d839c7 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -185,13 +185,13 @@ void Check64BitPortabilityImpl::returnIntegerError(const Token *tok) void Check64BitPortability::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - Check64BitPortabilityImpl check64BitPortability(&tokenizer, tokenizer.getSettings(), errorLogger); + Check64BitPortabilityImpl check64BitPortability(&tokenizer, tokenizer.getSettings(), *errorLogger); check64BitPortability.pointerassignment(); } void Check64BitPortability::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - Check64BitPortabilityImpl c(nullptr, settings, &errorLogger); + Check64BitPortabilityImpl c(nullptr, settings, errorLogger); c.assignmentAddressToIntegerError(nullptr); c.assignmentIntegerToAddressError(nullptr); c.returnIntegerError(nullptr); diff --git a/lib/check64bit.h b/lib/check64bit.h index 77e6fe871e8..7e853510be6 100644 --- a/lib/check64bit.h +++ b/lib/check64bit.h @@ -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 */ diff --git a/lib/checkassert.cpp b/lib/checkassert.cpp index f939ccff866..854a117e2d4 100644 --- a/lib/checkassert.cpp +++ b/lib/checkassert.cpp @@ -180,13 +180,13 @@ bool CheckAssertImpl::inSameScope(const Token* returnTok, const Token* assignTok void CheckAssert::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckAssertImpl checkAssert(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckAssertImpl checkAssert(&tokenizer, tokenizer.getSettings(), *errorLogger); checkAssert.assertWithSideEffects(); } void CheckAssert::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckAssertImpl c(nullptr, settings, &errorLogger); + CheckAssertImpl c(nullptr, settings, errorLogger); c.sideEffectInAssertError(nullptr, "function"); c.assignmentInAssertError(nullptr, "var"); } diff --git a/lib/checkassert.h b/lib/checkassert.h index 2bb9ddb7ac1..30e6757ff40 100644 --- a/lib/checkassert.h +++ b/lib/checkassert.h @@ -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(); diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 89203728bbe..cf528d8a83b 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -819,7 +819,7 @@ void CheckAutoVariablesImpl::errorInvalidDeallocation(const Token *tok, const Va void CheckAutoVariables::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckAutoVariablesImpl checkAutoVariables(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckAutoVariablesImpl checkAutoVariables(&tokenizer, tokenizer.getSettings(), *errorLogger); checkAutoVariables.assignFunctionArg(); checkAutoVariables.autoVariables(); checkAutoVariables.checkVarLifetime(); @@ -827,7 +827,7 @@ void CheckAutoVariables::runChecks(const Tokenizer &tokenizer, ErrorLogger *erro void CheckAutoVariables::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckAutoVariablesImpl c(nullptr,settings,&errorLogger); + CheckAutoVariablesImpl c(nullptr,settings,errorLogger); c.errorAutoVariableAssignment(nullptr, false); c.errorReturnReference(nullptr, ErrorPath{}, false); c.errorDanglingReference(nullptr, nullptr, ErrorPath{}); diff --git a/lib/checkautovariables.h b/lib/checkautovariables.h index cc800135fa9..2d410d2fb87 100644 --- a/lib/checkautovariables.h +++ b/lib/checkautovariables.h @@ -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 */ diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 5610d11ac63..a3276be336e 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -514,7 +514,7 @@ void CheckBoolImpl::returnValueBoolError(const Token *tok) void CheckBool::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckBoolImpl checkBool(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckBoolImpl checkBool(&tokenizer, tokenizer.getSettings(), *errorLogger); // Checks checkBool.checkComparisonOfBoolExpressionWithInt(); @@ -531,7 +531,7 @@ void CheckBool::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) void CheckBool::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckBoolImpl c(nullptr, settings, &errorLogger); + CheckBoolImpl c(nullptr, settings, errorLogger); c.assignBoolToPointerError(nullptr); c.assignBoolToFloatError(nullptr); c.comparisonOfFuncReturningBoolError(nullptr, "func_name"); diff --git a/lib/checkbool.h b/lib/checkbool.h index 3b5c943e2c6..ef0f721f5c9 100644 --- a/lib/checkbool.h +++ b/lib/checkbool.h @@ -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*/ diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 058d6c8557b..9d69539465d 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -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 &fileInfo, const Settings& settings, ErrorLogger &errorLogger) { - CheckBufferOverrunImpl dummy(nullptr, settings, &errorLogger); + CheckBufferOverrunImpl dummy(nullptr, settings, errorLogger); dummy. logChecker("CheckBufferOverrun::analyseWholeProgram"); @@ -1216,7 +1216,7 @@ void CheckBufferOverrunImpl::negativeMemoryAllocationSizeError(const Token* tok, void CheckBufferOverrun::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckBufferOverrunImpl checkBufferOverrun(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckBufferOverrunImpl checkBufferOverrun(&tokenizer, tokenizer.getSettings(), *errorLogger); checkBufferOverrun.arrayIndex(); checkBufferOverrun.pointerArithmetic(); checkBufferOverrun.bufferOverflow(); @@ -1229,7 +1229,7 @@ void CheckBufferOverrun::runChecks(const Tokenizer &tokenizer, ErrorLogger *erro void CheckBufferOverrun::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckBufferOverrunImpl c(nullptr, settings, &errorLogger); + CheckBufferOverrunImpl c(nullptr, settings, errorLogger); c.arrayIndexError(nullptr, std::vector(), std::vector()); c.pointerArithmeticError(nullptr, nullptr, nullptr); c.negativeIndexError(nullptr, std::vector(), std::vector()); diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index 62c6f9f54fd..73b34b19c02 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -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(); diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 10915d8317b..170be2578fe 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -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) {} @@ -3833,7 +3833,7 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list stl_containers_not_const; diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 2ae25832de4..f0b3d78a0b3 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -2097,7 +2097,7 @@ void CheckConditionImpl::compareValueOutOfTypeRangeError(const Token *comparison void CheckCondition::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckConditionImpl checkCondition(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckConditionImpl checkCondition(&tokenizer, tokenizer.getSettings(), *errorLogger); checkCondition.multiCondition(); checkCondition.clarifyCondition(); // not simplified because ifAssign checkCondition.multiCondition2(); @@ -2117,7 +2117,7 @@ void CheckCondition::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog void CheckCondition::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckConditionImpl c(nullptr, settings, &errorLogger); + CheckConditionImpl c(nullptr, settings, errorLogger); c.assignIfError(nullptr, nullptr, "", false); c.badBitmaskCheckError(nullptr); diff --git a/lib/checkcondition.h b/lib/checkcondition.h index 9dd04b3375f..49378eb5124 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -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 */ diff --git a/lib/checkexceptionsafety.cpp b/lib/checkexceptionsafety.cpp index 80893fe6d48..cb33d264887 100644 --- a/lib/checkexceptionsafety.cpp +++ b/lib/checkexceptionsafety.cpp @@ -414,7 +414,7 @@ void CheckExceptionSafety::runChecks(const Tokenizer &tokenizer, ErrorLogger *er if (tokenizer.isC()) return; - CheckExceptionSafetyImpl checkExceptionSafety(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckExceptionSafetyImpl checkExceptionSafety(&tokenizer, tokenizer.getSettings(), *errorLogger); checkExceptionSafety.destructors(); checkExceptionSafety.deallocThrow(); checkExceptionSafety.checkRethrowCopy(); @@ -426,7 +426,7 @@ void CheckExceptionSafety::runChecks(const Tokenizer &tokenizer, ErrorLogger *er void CheckExceptionSafety::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckExceptionSafetyImpl c(nullptr, settings, &errorLogger); + CheckExceptionSafetyImpl c(nullptr, settings, errorLogger); c.destructorsError(nullptr, "Class"); c.deallocThrowError(nullptr, "p"); c.rethrowCopyError(nullptr, "varname"); diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index 93457827471..3c002185e75 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -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 */ diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index a7cfbc9e242..d484b53dcd7 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -855,7 +855,7 @@ void CheckFunctionsImpl::useStandardLibraryError(const Token *tok, const std::st void CheckFunctions::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckFunctionsImpl checkFunctions(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckFunctionsImpl checkFunctions(&tokenizer, tokenizer.getSettings(), *errorLogger); checkFunctions.checkIgnoredReturnValue(); checkFunctions.checkMissingReturn(); // Missing "return" in exit path @@ -874,7 +874,7 @@ void CheckFunctions::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog void CheckFunctions::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckFunctionsImpl c(nullptr, settings, &errorLogger); + CheckFunctionsImpl c(nullptr, settings, errorLogger); for (auto i = settings.library.functionwarn().cbegin(); i != settings.library.functionwarn().cend(); ++i) { c.functionCalledError(nullptr, Severity::style, i->first, i->second.message); diff --git a/lib/checkfunctions.h b/lib/checkfunctions.h index a0847276859..fe3a5932d3d 100644 --- a/lib/checkfunctions.h +++ b/lib/checkfunctions.h @@ -73,7 +73,7 @@ class CPPCHECKLIB CheckFunctions : public Check { class CPPCHECKLIB CheckFunctionsImpl : public CheckImpl { public: /** This constructor is used when running checks. */ - CheckFunctionsImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckFunctionsImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** Check for functions that should not be used */ diff --git a/lib/checkimpl.cpp b/lib/checkimpl.cpp index 2b28b829277..fb1c71a66b3 100644 --- a/lib/checkimpl.cpp +++ b/lib/checkimpl.cpp @@ -24,25 +24,20 @@ #include "tokenize.h" #include "vfvalue.h" -#include #include void CheckImpl::reportError(const std::list &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty) { - assert(mErrorLogger); - // TODO: report debug warning when error is for a disabled severity const ErrorMessage errmsg(callstack, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, certainty); - mErrorLogger->reportErr(errmsg); + mErrorLogger.reportErr(errmsg); } void CheckImpl::reportError(ErrorPath errorPath, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty) { - assert(mErrorLogger); - // TODO: report debug warning when error is for a disabled severity const ErrorMessage errmsg(std::move(errorPath), mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, certainty); - mErrorLogger->reportErr(errmsg); + mErrorLogger.reportErr(errmsg); } bool CheckImpl::wrongData(const Token *tok, const char *str) diff --git a/lib/checkimpl.h b/lib/checkimpl.h index 36f04a23d1f..17f92da8553 100644 --- a/lib/checkimpl.h +++ b/lib/checkimpl.h @@ -37,7 +37,7 @@ class CPPCHECKLIB CheckImpl { protected: /** This constructor is used when running checks. */ - CheckImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : mTokenizer(tokenizer), mSettings(settings), mErrorLogger(errorLogger) {} public: @@ -47,7 +47,7 @@ class CPPCHECKLIB CheckImpl protected: const Tokenizer* const mTokenizer{}; const Settings& mSettings; - ErrorLogger* const mErrorLogger{}; + ErrorLogger& mErrorLogger; /** report an error */ void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg) { diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index 97a35c94953..9954d3b987c 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -382,7 +382,7 @@ void CheckInternal::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogg if (!tokenizer.getSettings().checks.isEnabled(Checks::internalCheck)) return; - CheckInternalImpl checkInternal(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckInternalImpl checkInternal(&tokenizer, tokenizer.getSettings(), *errorLogger); checkInternal.checkTokenMatchPatterns(); checkInternal.checkTokenSimpleMatchPatterns(); @@ -395,7 +395,7 @@ void CheckInternal::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogg void CheckInternal::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckInternalImpl c(nullptr, settings, &errorLogger); + CheckInternalImpl c(nullptr, settings, errorLogger); c.simplePatternError(nullptr, "class {", "Match"); c.complexPatternError(nullptr, "%type% ( )", "Match"); c.missingPercentCharacterError(nullptr, "%num", "Match"); diff --git a/lib/checkinternal.h b/lib/checkinternal.h index 5a87ff39054..08aacb335f5 100644 --- a/lib/checkinternal.h +++ b/lib/checkinternal.h @@ -60,7 +60,7 @@ class CPPCHECKLIB CheckInternal : public Check { class CPPCHECKLIB CheckInternalImpl : public CheckImpl { public: /** This constructor is used when running checks. */ - CheckInternalImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckInternalImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief %Check if a simple pattern is used inside Token::Match or Token::findmatch */ diff --git a/lib/checkio.cpp b/lib/checkio.cpp index ed915274d1c..03b551ab8ea 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -2052,7 +2052,7 @@ void CheckIOImpl::invalidScanfFormatWidthError(const Token* tok, nonneg int numF void CheckIO::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckIOImpl checkIO(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckIOImpl checkIO(&tokenizer, tokenizer.getSettings(), *errorLogger); checkIO.checkWrongPrintfScanfArguments(); checkIO.checkCoutCerrMisusage(); @@ -2062,7 +2062,7 @@ void CheckIO::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) void CheckIO::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckIOImpl c(nullptr, settings, &errorLogger); + CheckIOImpl c(nullptr, settings, errorLogger); c.coutCerrMisusageError(nullptr, "cout"); c.fflushOnInputStreamError(nullptr, "stdin"); c.ioWithoutPositioningError(nullptr); diff --git a/lib/checkio.h b/lib/checkio.h index 76e82cf56ea..77dbcfa8b06 100644 --- a/lib/checkio.h +++ b/lib/checkio.h @@ -72,7 +72,7 @@ class CPPCHECKLIB CheckIO : public Check { class CPPCHECKLIB CheckIOImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckIOImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckIOImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief %Check for missusage of std::cout */ diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 2bbc30a9ca0..655d11399ac 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -1280,13 +1280,13 @@ void CheckLeakAutoVarImpl::ret(const Token *tok, VarInfo &varInfo, const bool is void CheckLeakAutoVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckLeakAutoVarImpl checkLeakAutoVar(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckLeakAutoVarImpl checkLeakAutoVar(&tokenizer, tokenizer.getSettings(), *errorLogger); checkLeakAutoVar.check(); } void CheckLeakAutoVar::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckLeakAutoVarImpl c(nullptr, settings, &errorLogger); + CheckLeakAutoVarImpl c(nullptr, settings, errorLogger); c.deallocReturnError(nullptr, nullptr, "p"); c.configurationInfo(nullptr, { nullptr, VarInfo::USED }); // user configuration is needed to complete analysis c.doubleFreeError(nullptr, nullptr, "varname", 0); diff --git a/lib/checkleakautovar.h b/lib/checkleakautovar.h index f9fa4c26626..35e22025aef 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -123,7 +123,7 @@ class CPPCHECKLIB CheckLeakAutoVar : public Check { class CPPCHECKLIB CheckLeakAutoVarImpl : public CheckImpl { public: /** This constructor is used when running checks. */ - CheckLeakAutoVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckLeakAutoVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** check for leaks in all scopes */ diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 2ff3d366a5b..a0c91103bd5 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -31,7 +31,6 @@ #include "utils.h" #include -#include #include #include #include @@ -286,10 +285,8 @@ void CheckMemoryLeakImpl::reportErr(const Token *tok, Severity severity, const s void CheckMemoryLeakImpl::reportErr(const std::list &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe) const { - assert(mErrorLogger); - const ErrorMessage errmsg(callstack, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, Certainty::normal); - mErrorLogger->reportErr(errmsg); + mErrorLogger.reportErr(errmsg); } void CheckMemoryLeakImpl::memleakError(const Token *tok, const std::string &varname) const @@ -492,13 +489,13 @@ void CheckMemoryLeakInFunctionImpl::checkReallocUsage() void CheckMemoryLeakInFunction::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckMemoryLeakInFunctionImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckMemoryLeakInFunctionImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), *errorLogger); checkMemoryLeak.checkReallocUsage(); } void CheckMemoryLeakInFunction::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakInFunctionImpl c(nullptr, settings, &e); + CheckMemoryLeakInFunctionImpl c(nullptr, settings, e); c.memleakError(nullptr, "varname"); c.resourceLeakError(nullptr, "varname"); c.deallocuseError(nullptr, "varname"); @@ -696,13 +693,13 @@ void CheckMemoryLeakInClass::runChecks(const Tokenizer &tokenizer, ErrorLogger * if (!tokenizer.isCPP()) return; - CheckMemoryLeakInClassImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckMemoryLeakInClassImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), *errorLogger); checkMemoryLeak.check(); } void CheckMemoryLeakInClass::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakInClassImpl c(nullptr, settings, &e); + CheckMemoryLeakInClassImpl c(nullptr, settings, e); c.publicAllocationError(nullptr, "varname"); c.unsafeClassError(nullptr, "class", "class::varname"); } @@ -968,7 +965,7 @@ void CheckMemoryLeakStructMemberImpl::checkStructVariable(const Variable* const void CheckMemoryLeakStructMember::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckMemoryLeakStructMemberImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckMemoryLeakStructMemberImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), *errorLogger); checkMemoryLeak.check(); } @@ -1220,13 +1217,13 @@ void CheckMemoryLeakNoVarImpl::unsafeArgAllocError(const Token *tok, const std:: void CheckMemoryLeakNoVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckMemoryLeakNoVarImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckMemoryLeakNoVarImpl checkMemoryLeak(&tokenizer, tokenizer.getSettings(), *errorLogger); checkMemoryLeak.check(); } void CheckMemoryLeakNoVar::getErrorMessages(ErrorLogger& e, const Settings &settings) const { - CheckMemoryLeakNoVarImpl c(nullptr, settings, &e); + CheckMemoryLeakNoVarImpl c(nullptr, settings, e); c.functionCallLeak(nullptr, "funcName", "funcName"); c.returnValueNotUsedError(nullptr, "funcName"); c.unsafeArgAllocError(nullptr, "funcName", "shared_ptr", "int"); diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index 5377c7590ed..6dfb75fa269 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -175,7 +175,7 @@ class CPPCHECKLIB CheckMemoryLeakImpl : public CheckImpl { CheckMemoryLeakImpl(const CheckMemoryLeakImpl &) = delete; CheckMemoryLeakImpl& operator=(const CheckMemoryLeakImpl &) = delete; - CheckMemoryLeakImpl(const Tokenizer *t, const Settings &s, ErrorLogger *e) + CheckMemoryLeakImpl(const Tokenizer *t, const Settings &s, ErrorLogger &e) : CheckImpl(t, s, e) {} /** @brief What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */ @@ -254,7 +254,7 @@ class CPPCHECKLIB CheckMemoryLeakImpl : public CheckImpl { class CPPCHECKLIB CheckMemoryLeakInFunctionImpl : public CheckMemoryLeakImpl { public: /** @brief This constructor is used when running checks */ - CheckMemoryLeakInFunctionImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckMemoryLeakInFunctionImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckMemoryLeakImpl(tokenizer, settings, errorLogger) {} /** @@ -271,7 +271,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunctionImpl : public CheckMemoryLeakImpl { class CPPCHECKLIB CheckMemoryLeakInClassImpl : private CheckMemoryLeakImpl { public: - CheckMemoryLeakInClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckMemoryLeakInClassImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckMemoryLeakImpl(tokenizer, settings, errorLogger) {} void check(); @@ -292,7 +292,7 @@ class CPPCHECKLIB CheckMemoryLeakInClassImpl : private CheckMemoryLeakImpl { class CPPCHECKLIB CheckMemoryLeakStructMemberImpl : private CheckMemoryLeakImpl { public: - CheckMemoryLeakStructMemberImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckMemoryLeakStructMemberImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckMemoryLeakImpl(tokenizer, settings, errorLogger) {} void check(); @@ -309,7 +309,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMemberImpl : private CheckMemoryLeakImpl class CPPCHECKLIB CheckMemoryLeakNoVarImpl : private CheckMemoryLeakImpl { public: - CheckMemoryLeakNoVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckMemoryLeakNoVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckMemoryLeakImpl(tokenizer, settings, errorLogger) {} void check(); diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index ccca82ffd45..4c5a40db831 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -632,7 +632,7 @@ bool CheckNullPointer::analyseWholeProgram(const CTU::FileInfo &ctu, const std:: { (void)settings; - CheckNullPointerImpl dummy(nullptr, settings, &errorLogger); + CheckNullPointerImpl dummy(nullptr, settings, errorLogger); dummy. logChecker("CheckNullPointer::analyseWholeProgram"); @@ -694,7 +694,7 @@ bool CheckNullPointer::analyseWholeProgram(const CTU::FileInfo &ctu, const std:: void CheckNullPointer::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckNullPointerImpl checkNullPointer(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckNullPointerImpl checkNullPointer(&tokenizer, tokenizer.getSettings(), *errorLogger); checkNullPointer.nullPointer(); checkNullPointer.arithmetic(); checkNullPointer.nullConstantDereference(); @@ -702,7 +702,7 @@ void CheckNullPointer::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorL void CheckNullPointer::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckNullPointerImpl c(nullptr, settings, &errorLogger); + CheckNullPointerImpl c(nullptr, settings, errorLogger); c.nullPointerError(nullptr, "pointer", nullptr, false); c.pointerArithmeticError(nullptr, nullptr, false); // TODO: nullPointerArithmeticOutOfMemory diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index e663d77e79f..8b8c25545a1 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -80,7 +80,7 @@ class CPPCHECKLIB CheckNullPointer : public Check { class CPPCHECKLIB CheckNullPointerImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckNullPointerImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckNullPointerImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** diff --git a/lib/checkother.cpp b/lib/checkother.cpp index faefe185de3..6818ecac584 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -4789,7 +4789,7 @@ void CheckOtherImpl::overlappingWriteFunction(const Token *tok, const std::strin void CheckOther::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckOtherImpl checkOther(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckOtherImpl checkOther(&tokenizer, tokenizer.getSettings(), *errorLogger); // Checks checkOther.warningOldStylePointerCast(); @@ -4841,7 +4841,7 @@ void CheckOther::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) void CheckOther::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckOtherImpl c(nullptr, settings, &errorLogger); + CheckOtherImpl c(nullptr, settings, errorLogger); // error c.zerodivError(nullptr, nullptr); diff --git a/lib/checkother.h b/lib/checkother.h index 3610de54963..5d6a05c6d6f 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -127,7 +127,7 @@ class CPPCHECKLIB CheckOther : public Check { class CPPCHECKLIB CheckOtherImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckOtherImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckOtherImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** Is expression a comparison that checks if a nonzero (unsigned/pointer) expression is less than zero? */ diff --git a/lib/checkpostfixoperator.cpp b/lib/checkpostfixoperator.cpp index 87156ae5d2c..56de8b367f0 100644 --- a/lib/checkpostfixoperator.cpp +++ b/lib/checkpostfixoperator.cpp @@ -99,12 +99,12 @@ void CheckPostfixOperator::runChecks(const Tokenizer &tokenizer, ErrorLogger *er if (tokenizer.isC()) return; - CheckPostfixOperatorImpl checkPostfixOperator(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckPostfixOperatorImpl checkPostfixOperator(&tokenizer, tokenizer.getSettings(), *errorLogger); checkPostfixOperator.postfixOperator(); } void CheckPostfixOperator::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckPostfixOperatorImpl c(nullptr, settings, &errorLogger); + CheckPostfixOperatorImpl c(nullptr, settings, errorLogger); c.postfixOperatorError(nullptr); } diff --git a/lib/checkpostfixoperator.h b/lib/checkpostfixoperator.h index 407344f8fb9..4345d051cd0 100644 --- a/lib/checkpostfixoperator.h +++ b/lib/checkpostfixoperator.h @@ -59,7 +59,7 @@ class CPPCHECKLIB CheckPostfixOperator : public Check { class CPPCHECKLIB CheckPostfixOperatorImpl : public CheckImpl { public: /** This constructor is used when running checks. */ - CheckPostfixOperatorImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckPostfixOperatorImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** Check postfix operators */ diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 3a24c39e845..3f1c86a895d 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -500,7 +500,7 @@ void CheckSizeofImpl::arithOperationsOnVoidPointerError(const Token* tok, const void CheckSizeof::runChecks(const Tokenizer& tokenizer, ErrorLogger* errorLogger) { - CheckSizeofImpl checkSizeof(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckSizeofImpl checkSizeof(&tokenizer, tokenizer.getSettings(), *errorLogger); // Checks checkSizeof.sizeofsizeof(); @@ -515,7 +515,7 @@ void CheckSizeof::runChecks(const Tokenizer& tokenizer, ErrorLogger* errorLogger void CheckSizeof::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckSizeofImpl c(nullptr, settings, &errorLogger); + CheckSizeofImpl c(nullptr, settings, errorLogger); c.sizeofForArrayParameterError(nullptr); c.sizeofForPointerError(nullptr, "varname"); c.divideBySizeofError(nullptr, "memset"); diff --git a/lib/checksizeof.h b/lib/checksizeof.h index 6a51006ecfd..1ee6ed8e26d 100644 --- a/lib/checksizeof.h +++ b/lib/checksizeof.h @@ -66,7 +66,7 @@ class CPPCHECKLIB CheckSizeof : public Check { class CPPCHECKLIB CheckSizeofImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckSizeofImpl(const Tokenizer* tokenizer, const Settings& settings, ErrorLogger* errorLogger) + CheckSizeofImpl(const Tokenizer* tokenizer, const Settings& settings, ErrorLogger& errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief %Check for 'sizeof sizeof ..' */ diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 7183074c92c..cc256fd5c73 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -3459,7 +3459,7 @@ void CheckStl::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) return; } - CheckStlImpl checkStl(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckStlImpl checkStl(&tokenizer, tokenizer.getSettings(), *errorLogger); checkStl.erase(); checkStl.if_find(); checkStl.checkFindInsert(); @@ -3492,7 +3492,7 @@ void CheckStl::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) void CheckStl::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckStlImpl c(nullptr, settings, &errorLogger); + CheckStlImpl c(nullptr, settings, errorLogger); c.outOfBoundsError(nullptr, "container", nullptr, "x", nullptr); c.invalidIteratorError(nullptr, "iterator"); c.iteratorsError(nullptr, "container1", "container2"); diff --git a/lib/checkstl.h b/lib/checkstl.h index 1434ab1fdec..6d78d4c0de2 100644 --- a/lib/checkstl.h +++ b/lib/checkstl.h @@ -83,7 +83,7 @@ class CPPCHECKLIB CheckStl : public Check { class CPPCHECKLIB CheckStlImpl : public CheckImpl { public: /** This constructor is used when running checks. */ - CheckStlImpl(const Tokenizer* tokenizer, const Settings& settings, ErrorLogger* errorLogger) + CheckStlImpl(const Tokenizer* tokenizer, const Settings& settings, ErrorLogger& errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** Accessing container out of bounds using ValueFlow */ diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index 488a4bc2cae..41d2c833762 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -473,7 +473,7 @@ void CheckStringImpl::sprintfOverlappingDataError(const Token *funcTok, const To void CheckString::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckStringImpl checkString(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckStringImpl checkString(&tokenizer, tokenizer.getSettings(), *errorLogger); // Checks checkString.strPlusChar(); @@ -487,7 +487,7 @@ void CheckString::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger void CheckString::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckStringImpl c(nullptr, settings, &errorLogger); + CheckStringImpl c(nullptr, settings, errorLogger); c.stringLiteralWriteError(nullptr, nullptr); c.sprintfOverlappingDataError(nullptr, nullptr, "varname"); c.strPlusCharError(nullptr); diff --git a/lib/checkstring.h b/lib/checkstring.h index cbb5272d083..ad68c1c8565 100644 --- a/lib/checkstring.h +++ b/lib/checkstring.h @@ -65,7 +65,7 @@ class CPPCHECKLIB CheckString : public Check { class CPPCHECKLIB CheckStringImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckStringImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckStringImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief undefined behaviour, writing string literal */ diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 15b70c47151..2190d94be65 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -534,7 +534,7 @@ void CheckTypeImpl::floatToIntegerOverflowError(const Token *tok, const ValueFlo void CheckType::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { // These are not "simplified" because casts can't be ignored - CheckTypeImpl checkType(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckTypeImpl checkType(&tokenizer, tokenizer.getSettings(), *errorLogger); checkType.checkTooBigBitwiseShift(); checkType.checkIntegerOverflow(); checkType.checkSignConversion(); @@ -544,7 +544,7 @@ void CheckType::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) void CheckType::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckTypeImpl c(nullptr, settings, &errorLogger); + CheckTypeImpl c(nullptr, settings, errorLogger); c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64)); c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31)); c.integerOverflowError(nullptr, ValueFlow::Value(1LL<<32)); diff --git a/lib/checktype.h b/lib/checktype.h index c50a7238307..7653cb27805 100644 --- a/lib/checktype.h +++ b/lib/checktype.h @@ -70,7 +70,7 @@ class CPPCHECKLIB CheckType : public Check { class CPPCHECKLIB CheckTypeImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckTypeImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckTypeImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief %Check for bitwise shift with too big right operand */ diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index dcc454288df..a1508b78c03 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1753,7 +1753,7 @@ bool CheckUninitVar::analyseWholeProgram(const CTU::FileInfo &ctu, const std::li { (void)settings; - CheckUninitVarImpl dummy(nullptr, settings, &errorLogger); + CheckUninitVarImpl dummy(nullptr, settings, errorLogger); dummy. logChecker("CheckUninitVar::analyseWholeProgram"); @@ -1799,14 +1799,14 @@ bool CheckUninitVar::analyseWholeProgram(const CTU::FileInfo &ctu, const std::li void CheckUninitVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckUninitVarImpl checkUninitVar(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckUninitVarImpl checkUninitVar(&tokenizer, tokenizer.getSettings(), *errorLogger); checkUninitVar.valueFlowUninit(); checkUninitVar.check(); } void CheckUninitVar::getErrorMessages(ErrorLogger& errorLogger, const Settings& settings) const { - CheckUninitVarImpl c(nullptr, settings, &errorLogger); + CheckUninitVarImpl c(nullptr, settings, errorLogger); ValueFlow::Value v{}; diff --git a/lib/checkuninitvar.h b/lib/checkuninitvar.h index 588cfa22fea..0fec9cdcf60 100644 --- a/lib/checkuninitvar.h +++ b/lib/checkuninitvar.h @@ -88,7 +88,7 @@ class CPPCHECKLIB CheckUninitVar : public Check { class CPPCHECKLIB CheckUninitVarImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckUninitVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckUninitVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} enum Alloc : std::uint8_t { NO_ALLOC, NO_CTOR_CALL, CTOR_CALL, ARRAY }; diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 2cfe0a86c64..d2e3a9722b4 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1727,7 +1727,7 @@ bool CheckUnusedVarImpl::isEmptyType(const Type* type) void CheckUnusedVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckUnusedVarImpl checkUnusedVar(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckUnusedVarImpl checkUnusedVar(&tokenizer, tokenizer.getSettings(), *errorLogger); // Coding style checks checkUnusedVar.checkStructMemberUsage(); @@ -1736,7 +1736,7 @@ void CheckUnusedVar::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLog void CheckUnusedVar::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckUnusedVarImpl c(nullptr, settings, &errorLogger); + CheckUnusedVarImpl c(nullptr, settings, errorLogger); c.unusedVariableError(nullptr, "varname"); c.allocatedButUnusedVariableError(nullptr, "varname"); c.unreadVariableError(nullptr, "varname", false); diff --git a/lib/checkunusedvar.h b/lib/checkunusedvar.h index 82c8f22cb04..1bc661b6e78 100644 --- a/lib/checkunusedvar.h +++ b/lib/checkunusedvar.h @@ -70,7 +70,7 @@ class CPPCHECKLIB CheckUnusedVar : public Check { class CPPCHECKLIB CheckUnusedVarImpl : public CheckImpl { public: /** @brief This constructor is used when running checks. */ - CheckUnusedVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckUnusedVarImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} /** @brief %Check for unused function variables */ diff --git a/lib/checkvaarg.cpp b/lib/checkvaarg.cpp index 07e41ca395e..98640dbf3e7 100644 --- a/lib/checkvaarg.cpp +++ b/lib/checkvaarg.cpp @@ -175,14 +175,14 @@ void CheckVaargImpl::va_start_subsequentCallsError(const Token *tok, const std:: void CheckVaarg::runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - CheckVaargImpl check(&tokenizer, tokenizer.getSettings(), errorLogger); + CheckVaargImpl check(&tokenizer, tokenizer.getSettings(), *errorLogger); check.va_start_argument(); check.va_list_usage(); } void CheckVaarg::getErrorMessages(ErrorLogger& errorLogger, const Settings &settings) const { - CheckVaargImpl c(nullptr, settings, &errorLogger); + CheckVaargImpl c(nullptr, settings, errorLogger); c.wrongParameterTo_va_start_error(nullptr, "arg1", "arg2"); c.referenceAs_va_start_error(nullptr, "arg1"); c.va_end_missingError(nullptr, "vl"); diff --git a/lib/checkvaarg.h b/lib/checkvaarg.h index 5e72443f916..1239d4ae2d9 100644 --- a/lib/checkvaarg.h +++ b/lib/checkvaarg.h @@ -62,7 +62,7 @@ class CPPCHECKLIB CheckVaarg : public Check { class CPPCHECKLIB CheckVaargImpl : public CheckImpl { public: - CheckVaargImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger) + CheckVaargImpl(const Tokenizer *tokenizer, const Settings &settings, ErrorLogger &errorLogger) : CheckImpl(tokenizer, settings, errorLogger) {} void va_start_argument(); diff --git a/test/test64bit.cpp b/test/test64bit.cpp index ca2654b12f1..cc96da48577 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -49,7 +49,7 @@ class Test64BitPortability : public TestFixture { SimpleTokenizer tokenizer(settings, *this, cpp); ASSERT_LOC(tokenizer.tokenize(code), file, line); - Check64BitPortabilityImpl check64BitPortability(&tokenizer, settings, this); + Check64BitPortabilityImpl check64BitPortability(&tokenizer, settings, *this); check64BitPortability.pointerassignment(); } diff --git a/test/testcharvar.cpp b/test/testcharvar.cpp index 347557bd051..7d4a17489fc 100644 --- a/test/testcharvar.cpp +++ b/test/testcharvar.cpp @@ -47,7 +47,7 @@ class TestCharVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check char variable usage.. - CheckOtherImpl checkOther(&tokenizer, settings, this); + CheckOtherImpl checkOther(&tokenizer, settings, *this); checkOther.checkCharVariable(); } diff --git a/test/testclass.cpp b/test/testclass.cpp index 8fba8d4a340..7f1a668cae1 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -270,7 +270,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkCopyCtorAndEqOperator)(); } @@ -371,7 +371,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings0, this); + CheckClassImpl checkClass(&tokenizer, settings0, *this); (checkClass.checkExplicitConstructors)(); } @@ -528,7 +528,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); (checkClass.checkDuplInheritedMembers)(); } @@ -752,7 +752,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings3, this); + CheckClassImpl checkClass(&tokenizer, settings3, *this); checkClass.copyconstructors(); } @@ -1223,7 +1223,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings0, this); + CheckClassImpl checkClass(&tokenizer, settings0, *this); checkClass.operatorEqRetRefThis(); } @@ -1694,7 +1694,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); checkClass.operatorEqToSelf(); } @@ -2657,7 +2657,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, s, this); + CheckClassImpl checkClass(&tokenizer, s, *this); checkClass.virtualDestructor(); } @@ -2994,7 +2994,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); checkClass.checkMemset(); } @@ -3640,7 +3640,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); checkClass.thisSubtraction(); } @@ -3680,7 +3680,7 @@ class TestClass : public TestFixture { SimpleTokenizer tokenizer(settings, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkConst)(); } @@ -7863,7 +7863,7 @@ class TestClass : public TestFixture { SimpleTokenizer tokenizer(settings2, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckClassImpl checkClass(&tokenizer, settings2, this); + CheckClassImpl checkClass(&tokenizer, settings2, *this); checkClass.initializerListOrder(); } @@ -8017,7 +8017,7 @@ class TestClass : public TestFixture { SimpleTokenizer tokenizer(settings, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); checkClass.initializationListUsage(); } @@ -8241,7 +8241,7 @@ class TestClass : public TestFixture { SimpleTokenizer tokenizer(settings0, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckClassImpl checkClass(&tokenizer, settings0, this); + CheckClassImpl checkClass(&tokenizer, settings0, *this); (checkClass.checkSelfInitialization)(); } @@ -8351,7 +8351,7 @@ class TestClass : public TestFixture { SimpleTokenizer tokenizer(settings, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); checkClass.checkVirtualFunctionCallInConstructor(); } @@ -8696,7 +8696,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkOverride)(); } @@ -8908,7 +8908,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkUselessOverride)(); } @@ -9098,7 +9098,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkUnsafeClassRefMember)(); } @@ -9116,7 +9116,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); (checkClass.checkThisUseAfterFree)(); } @@ -9353,7 +9353,7 @@ class TestClass : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check.. - CheckClassImpl checkClass(&tokenizer, settings, this); + CheckClassImpl checkClass(&tokenizer, settings, *this); (checkClass.checkReturnByReference)(); } diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index b4f17cd25b8..5f2fd228dc4 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -52,7 +52,7 @@ class TestConstructors : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check class constructors.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); checkClass.constructors(); } diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index be0b3e7ad3d..b72b6524872 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -50,7 +50,7 @@ class TestIncompleteStatement : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check for incomplete statements.. - CheckOtherImpl checkOther(&tokenizer, settings1, this); + CheckOtherImpl checkOther(&tokenizer, settings1, *this); checkOther.checkIncompleteStatement(); } diff --git a/test/testio.cpp b/test/testio.cpp index c622bc5936d..8888c17e5ea 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -109,7 +109,7 @@ class TestIO : public TestFixture { // Check.. if (options.onlyFormatStr) { - CheckIOImpl checkIO(&tokenizer, settings1, this); + CheckIOImpl checkIO(&tokenizer, settings1, *this); checkIO.checkWrongPrintfScanfArguments(); return; } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 6e3d28010a1..fda118826bb 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -44,7 +44,7 @@ class TestMemleak : public TestFixture { SimpleTokenizer tokenizer(settingsDefault, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - const CheckMemoryLeakImpl c(&tokenizer, settingsDefault, this); + const CheckMemoryLeakImpl c(&tokenizer, settingsDefault, *this); return (c.functionReturnType)(&tokenizer.getSymbolDatabase()->scopeList.front().functionList.front()); } @@ -93,7 +93,7 @@ class TestMemleak : public TestFixture { // there is no allocation const Token *tok = Token::findsimplematch(tokenizer.tokens(), "ret ="); - const CheckMemoryLeakImpl check(&tokenizer, settingsDefault, nullptr); + const CheckMemoryLeakImpl check(&tokenizer, settingsDefault, *this); ASSERT_EQUALS(CheckMemoryLeakImpl::No, check.getAllocationType(tok->tokAt(2), 1)); } }; @@ -119,7 +119,7 @@ class TestMemleakInFunction : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. - CheckMemoryLeakInFunctionImpl checkMemoryLeak(&tokenizer, settings, this); + CheckMemoryLeakInFunctionImpl checkMemoryLeak(&tokenizer, settings, *this); checkMemoryLeak.checkReallocUsage(); } @@ -501,7 +501,7 @@ class TestMemleakInClass : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. - CheckMemoryLeakInClassImpl checkMemoryLeak(&tokenizer, settings, this); + CheckMemoryLeakInClassImpl checkMemoryLeak(&tokenizer, settings, *this); (checkMemoryLeak.check)(); } @@ -1706,7 +1706,7 @@ class TestMemleakStructMember : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. - CheckMemoryLeakStructMemberImpl checkMemoryLeakStructMember(&tokenizer, settings, this); + CheckMemoryLeakStructMemberImpl checkMemoryLeakStructMember(&tokenizer, settings, *this); (checkMemoryLeakStructMember.check)(); } @@ -2388,7 +2388,7 @@ class TestMemleakNoVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for memory leaks.. - CheckMemoryLeakNoVarImpl checkMemoryLeakNoVar(&tokenizer, settings, this); + CheckMemoryLeakNoVarImpl checkMemoryLeakNoVar(&tokenizer, settings, *this); (checkMemoryLeakNoVar.check)(); } diff --git a/test/testother.cpp b/test/testother.cpp index 2394cfefe7c..2cd7ebb4959 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2055,7 +2055,7 @@ class TestOther : public TestFixture { SimpleTokenizer tokenizerCpp(settings, *this); ASSERT_LOC(tokenizerCpp.tokenize(code), file, line); - CheckOtherImpl checkOtherCpp(&tokenizerCpp, settings, this); + CheckOtherImpl checkOtherCpp(&tokenizerCpp, settings, *this); checkOtherCpp.warningOldStylePointerCast(); checkOtherCpp.warningDangerousTypeCast(); } @@ -2341,7 +2341,7 @@ class TestOther : public TestFixture { SimpleTokenizer tokenizerCpp(settings, *this); ASSERT_LOC(tokenizerCpp.tokenize(code), file, line); - CheckOtherImpl checkOtherCpp(&tokenizerCpp, settings, this); + CheckOtherImpl checkOtherCpp(&tokenizerCpp, settings, *this); checkOtherCpp.warningIntToPointerCast(); } @@ -2380,7 +2380,7 @@ class TestOther : public TestFixture { SimpleTokenizer tokenizer(settings, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckOtherImpl checkOtherCpp(&tokenizer, settings, this); + CheckOtherImpl checkOtherCpp(&tokenizer, settings, *this); checkOtherCpp.invalidPointerCast(); } diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index 07b7c03ca00..2277039820f 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -38,7 +38,7 @@ class TestPostfixOperator : public TestFixture { SimpleTokenizer tokenizer(settings, *this); ASSERT_LOC(tokenizer.tokenize(code), file, line); - CheckPostfixOperatorImpl checkPostfixOperator(&tokenizer, settings, this); + CheckPostfixOperatorImpl checkPostfixOperator(&tokenizer, settings, *this); checkPostfixOperator.postfixOperator(); } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 0d71efbc897..b9e8a623cb7 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -127,7 +127,7 @@ class TestUninitVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for redundant code.. - CheckUninitVarImpl checkuninitvar(&tokenizer, settings1, this); + CheckUninitVarImpl checkuninitvar(&tokenizer, settings1, *this); checkuninitvar.check(); } @@ -137,7 +137,7 @@ class TestUninitVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for redundant code.. - CheckUninitVarImpl checkuninitvar(&tokenizer, settings, this); + CheckUninitVarImpl checkuninitvar(&tokenizer, settings, *this); checkuninitvar.check(); } @@ -3673,7 +3673,7 @@ class TestUninitVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for redundant code.. - CheckUninitVarImpl checkuninitvar(&tokenizer, settings, this); + CheckUninitVarImpl checkuninitvar(&tokenizer, settings, *this); (checkuninitvar.valueFlowUninit)(); } diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index 06c41bbb9c2..4a2a6ca1894 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -104,7 +104,7 @@ class TestUnusedPrivateFunction : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check for unused private functions.. - CheckClassImpl checkClass(&tokenizer, settings1, this); + CheckClassImpl checkClass(&tokenizer, settings1, *this); checkClass.privateFunctions(); } diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index ae44305ef6a..2efe658b52e 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -291,7 +291,7 @@ class TestUnusedVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for unused variables.. - CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, this); + CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, *this); checkUnusedVar.checkFunctionVariableUsage(); } @@ -311,7 +311,7 @@ class TestUnusedVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); // Check for unused variables.. - CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, this); + CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, *this); (checkUnusedVar.checkStructMemberUsage)(); } @@ -324,7 +324,7 @@ class TestUnusedVar : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check for unused variables.. - CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, this); + CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, *this); (checkUnusedVar.checkStructMemberUsage)(); } @@ -337,7 +337,7 @@ class TestUnusedVar : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); // Check for unused variables.. - CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, this); + CheckUnusedVarImpl checkUnusedVar(&tokenizer, settings, *this); (checkUnusedVar.checkFunctionVariableUsage)(); } From 25e8a1e79368e4d383745c3db6d55992c106be71 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 31 May 2026 17:42:38 +0200 Subject: [PATCH 3/3] pass `ErrorLogger` by reference into `Check::runChecks()` --- lib/check.h | 2 +- lib/check64bit.cpp | 4 ++-- lib/check64bit.h | 2 +- lib/checkassert.cpp | 4 ++-- lib/checkassert.h | 2 +- lib/checkautovariables.cpp | 4 ++-- lib/checkautovariables.h | 2 +- lib/checkbool.cpp | 4 ++-- lib/checkbool.h | 2 +- lib/checkbufferoverrun.cpp | 4 ++-- lib/checkbufferoverrun.h | 2 +- lib/checkclass.cpp | 4 ++-- lib/checkclass.h | 2 +- lib/checkcondition.cpp | 4 ++-- lib/checkcondition.h | 2 +- lib/checkexceptionsafety.cpp | 4 ++-- lib/checkexceptionsafety.h | 2 +- lib/checkfunctions.cpp | 4 ++-- lib/checkfunctions.h | 2 +- lib/checkinternal.cpp | 4 ++-- lib/checkinternal.h | 2 +- lib/checkio.cpp | 4 ++-- lib/checkio.h | 2 +- lib/checkleakautovar.cpp | 4 ++-- lib/checkleakautovar.h | 2 +- lib/checkmemoryleak.cpp | 16 ++++++++-------- lib/checkmemoryleak.h | 8 ++++---- lib/checknullpointer.cpp | 4 ++-- lib/checknullpointer.h | 2 +- lib/checkother.cpp | 4 ++-- lib/checkother.h | 2 +- lib/checkpostfixoperator.cpp | 4 ++-- lib/checkpostfixoperator.h | 2 +- lib/checksizeof.cpp | 4 ++-- lib/checksizeof.h | 2 +- lib/checkstl.cpp | 4 ++-- lib/checkstl.h | 2 +- lib/checkstring.cpp | 4 ++-- lib/checkstring.h | 2 +- lib/checktype.cpp | 4 ++-- lib/checktype.h | 2 +- lib/checkuninitvar.cpp | 4 ++-- lib/checkuninitvar.h | 2 +- lib/checkunusedvar.cpp | 4 ++-- lib/checkunusedvar.h | 2 +- lib/checkvaarg.cpp | 4 ++-- lib/checkvaarg.h | 2 +- lib/cppcheck.cpp | 2 +- test/fixture.h | 2 +- test/testassert.cpp | 2 +- test/testautovariables.cpp | 2 +- test/testbool.cpp | 2 +- test/testbufferoverrun.cpp | 6 +++--- test/testcondition.cpp | 6 +++--- test/testexceptionsafety.cpp | 2 +- test/testfunctions.cpp | 2 +- test/testgarbage.cpp | 2 +- test/testinternal.cpp | 2 +- test/testio.cpp | 2 +- test/testleakautovar.cpp | 10 +++++----- test/testnullpointer.cpp | 4 ++-- test/testother.cpp | 6 +++--- test/testsizeof.cpp | 4 ++-- test/teststl.cpp | 6 +++--- test/teststring.cpp | 2 +- test/testtype.cpp | 6 +++--- test/testvaarg.cpp | 2 +- 67 files changed, 115 insertions(+), 115 deletions(-) diff --git a/lib/check.h b/lib/check.h index 2981cfb86cf..8dda3e41825 100644 --- a/lib/check.h +++ b/lib/check.h @@ -62,7 +62,7 @@ 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; diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index bae14d839c7..345d66d9846 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -183,9 +183,9 @@ 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); + Check64BitPortabilityImpl check64BitPortability(&tokenizer, tokenizer.getSettings(), errorLogger); check64BitPortability.pointerassignment(); } diff --git a/lib/check64bit.h b/lib/check64bit.h index 7e853510be6..4354d2217ba 100644 --- a/lib/check64bit.h +++ b/lib/check64bit.h @@ -49,7 +49,7 @@ 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; diff --git a/lib/checkassert.cpp b/lib/checkassert.cpp index 854a117e2d4..1d0ecde7959 100644 --- a/lib/checkassert.cpp +++ b/lib/checkassert.cpp @@ -178,9 +178,9 @@ 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); + CheckAssertImpl checkAssert(&tokenizer, tokenizer.getSettings(), errorLogger); checkAssert.assertWithSideEffects(); } diff --git a/lib/checkassert.h b/lib/checkassert.h index 30e6757ff40..2db9d804fcb 100644 --- a/lib/checkassert.h +++ b/lib/checkassert.h @@ -47,7 +47,7 @@ class CPPCHECKLIB CheckAssert : public Check { private: /** run checks, the token list is not simplified */ - 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; std::string classInfo() const override { diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index cf528d8a83b..0493f3ea459 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -817,9 +817,9 @@ 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); + CheckAutoVariablesImpl checkAutoVariables(&tokenizer, tokenizer.getSettings(), errorLogger); checkAutoVariables.assignFunctionArg(); checkAutoVariables.autoVariables(); checkAutoVariables.checkVarLifetime(); diff --git a/lib/checkautovariables.h b/lib/checkautovariables.h index 2d410d2fb87..23d7a55a488 100644 --- a/lib/checkautovariables.h +++ b/lib/checkautovariables.h @@ -52,7 +52,7 @@ 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; diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index a3276be336e..3d36c9936a1 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -512,9 +512,9 @@ 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); + CheckBoolImpl checkBool(&tokenizer, tokenizer.getSettings(), errorLogger); // Checks checkBool.checkComparisonOfBoolExpressionWithInt(); diff --git a/lib/checkbool.h b/lib/checkbool.h index ef0f721f5c9..53cc19c2486 100644 --- a/lib/checkbool.h +++ b/lib/checkbool.h @@ -46,7 +46,7 @@ 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; diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 9d69539465d..9beef9c3079 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1214,9 +1214,9 @@ 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); + CheckBufferOverrunImpl checkBufferOverrun(&tokenizer, tokenizer.getSettings(), errorLogger); checkBufferOverrun.arrayIndex(); checkBufferOverrun.pointerArithmetic(); checkBufferOverrun.bufferOverflow(); diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index 73b34b19c02..566ed76bd85 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -64,7 +64,7 @@ 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; diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 170be2578fe..e917c95191e 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3882,12 +3882,12 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo &ctu, const std::listname() + "::runChecks", mTimerResults, [&]() { - c->runChecks(tokenizer, &mErrorLogger); + c->runChecks(tokenizer, mErrorLogger); }); } } diff --git a/test/fixture.h b/test/fixture.h index b927dc5de65..c5828033fd7 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -139,7 +139,7 @@ class TestFixture : public ErrorLogger { return check; } - static void runChecks(Check& check, const Tokenizer &tokenizer, ErrorLogger *errorLogger) + static void runChecks(Check& check, const Tokenizer &tokenizer, ErrorLogger& errorLogger) { check.runChecks(tokenizer, errorLogger); } diff --git a/test/testassert.cpp b/test/testassert.cpp index 651897af057..80bb5d3b827 100644 --- a/test/testassert.cpp +++ b/test/testassert.cpp @@ -40,7 +40,7 @@ class TestAssert : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckAssert check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 2474c2fe6a5..47484d7023e 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -48,7 +48,7 @@ class TestAutoVariables : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckAutoVariables check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { diff --git a/test/testbool.cpp b/test/testbool.cpp index 6156e089aee..6074bbab46a 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -89,7 +89,7 @@ class TestBool : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckBool check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 9dc62f11708..54fcabab6d1 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -57,7 +57,7 @@ class TestBufferOverrun : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckBufferOverrun check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } // TODO: get rid of this @@ -67,7 +67,7 @@ class TestBufferOverrun : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckBufferOverrun check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) @@ -80,7 +80,7 @@ class TestBufferOverrun : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckBufferOverrun check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { diff --git a/test/testcondition.cpp b/test/testcondition.cpp index e5aedae6609..3143b6eb201 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -150,7 +150,7 @@ class TestCondition : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckCondition check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) @@ -163,7 +163,7 @@ class TestCondition : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckCondition check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void assignAndCompare() { @@ -528,7 +528,7 @@ class TestCondition : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckCondition check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void multicompare() { diff --git a/test/testexceptionsafety.cpp b/test/testexceptionsafety.cpp index 46c995c231b..1be46fbf282 100644 --- a/test/testexceptionsafety.cpp +++ b/test/testexceptionsafety.cpp @@ -76,7 +76,7 @@ class TestExceptionSafety : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckExceptionSafety check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void destructors() { diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 9ddb4c1f43c..788ff7a0d14 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -133,7 +133,7 @@ class TestFunctions : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckFunctions check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void prohibitedFunctions_posix() { diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 289b22b284e..7d91a013940 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -287,7 +287,7 @@ class TestGarbage : public TestFixture { // call all "runChecks" in all registered Check classes for (Check * const c : CheckInstances::get()) { - c->runChecks(tokenizer, this); + c->runChecks(tokenizer, *this); } return tokenizer.tokens()->stringifyList(false, false, false, true, false, nullptr, nullptr); diff --git a/test/testinternal.cpp b/test/testinternal.cpp index b724c860fae..61c36a8e7dd 100644 --- a/test/testinternal.cpp +++ b/test/testinternal.cpp @@ -57,7 +57,7 @@ class TestInternal : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckInternal check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void simplePatternInTokenMatch() { diff --git a/test/testio.cpp b/test/testio.cpp index 8888c17e5ea..15a65ef79c9 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -114,7 +114,7 @@ class TestIO : public TestFixture { return; } CheckIO check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void coutCerrMisusage() { diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 265e31bf3c2..b7f8b024a8c 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -236,7 +236,7 @@ class TestLeakAutoVar : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckLeakAutoVar check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void assign1() { @@ -3267,7 +3267,7 @@ class TestLeakAutoVarRecursiveCountLimit : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckLeakAutoVar check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { @@ -3314,7 +3314,7 @@ class TestLeakAutoVarStrcpy : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckLeakAutoVar check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { @@ -3419,7 +3419,7 @@ class TestLeakAutoVarWindows : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckLeakAutoVar check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { @@ -3492,7 +3492,7 @@ class TestLeakAutoVarPosix : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckLeakAutoVar check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 3e9d4011500..b628d294a59 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -200,7 +200,7 @@ class TestNullPointer : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckNullPointer check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) @@ -212,7 +212,7 @@ class TestNullPointer : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckNullPointer check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } diff --git a/test/testother.cpp b/test/testother.cpp index 2cd7ebb4959..e720d9c7224 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -368,7 +368,7 @@ class TestOther : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckOther check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } struct CheckPOptions @@ -385,7 +385,7 @@ class TestOther : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckOther check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } template @@ -12315,7 +12315,7 @@ class TestOther : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckOther check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void testEvaluationOrder() { diff --git a/test/testsizeof.cpp b/test/testsizeof.cpp index ee9416a65bc..9337252f92c 100644 --- a/test/testsizeof.cpp +++ b/test/testsizeof.cpp @@ -55,7 +55,7 @@ class TestSizeof : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckSizeof check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) @@ -67,7 +67,7 @@ class TestSizeof : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckSizeof check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void sizeofsizeof() { diff --git a/test/teststl.cpp b/test/teststl.cpp index 18549e08f9f..51fab0e6021 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -200,7 +200,7 @@ class TestStl : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckStl check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } // TODO: get rid of this @@ -211,7 +211,7 @@ class TestStl : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckStl check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } #define checkNormal(...) checkNormal_(__FILE__, __LINE__, __VA_ARGS__) @@ -222,7 +222,7 @@ class TestStl : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckStl check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void outOfBounds() { diff --git a/test/teststring.cpp b/test/teststring.cpp index 7f28f58c80a..80073ac7d91 100644 --- a/test/teststring.cpp +++ b/test/teststring.cpp @@ -75,7 +75,7 @@ class TestString : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckString check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void stringLiteralWrite() { diff --git a/test/testtype.cpp b/test/testtype.cpp index 80c3dfd32b8..2bcab8c91dc 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -62,7 +62,7 @@ class TestType : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckType check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } // TODO: get rid of this @@ -74,7 +74,7 @@ class TestType : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckType check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } struct CheckPOptions @@ -94,7 +94,7 @@ class TestType : public TestFixture { ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); CheckType check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void checkTooBigShift_Unix32() { diff --git a/test/testvaarg.cpp b/test/testvaarg.cpp index 3f44b687ff3..826438fe355 100644 --- a/test/testvaarg.cpp +++ b/test/testvaarg.cpp @@ -39,7 +39,7 @@ class TestVaarg : public TestFixture { ASSERT_LOC(tokenizer.tokenize(code), file, line); CheckVaarg check; - runChecks(check, tokenizer, this); + runChecks(check, tokenizer, *this); } void run() override {