diff --git a/lib/checkassert.h b/lib/checkassert.h index 4ddb8e156..a9693dff9 100644 --- a/lib/checkassert.h +++ b/lib/checkassert.h @@ -41,8 +41,6 @@ class Token; */ class CPPCHECKLIB CheckAssert : public Check { - friend class TestFixture; - public: CheckAssert() : Check(myName()) {} diff --git a/lib/checkautovariables.h b/lib/checkautovariables.h index fa4b1d92f..236ab1f7d 100644 --- a/lib/checkautovariables.h +++ b/lib/checkautovariables.h @@ -45,8 +45,6 @@ namespace ValueFlow { class CPPCHECKLIB CheckAutoVariables : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckClass */ CheckAutoVariables() : Check(myName()) {} diff --git a/lib/checkbool.h b/lib/checkbool.h index 3c185095c..fa69b4e3e 100644 --- a/lib/checkbool.h +++ b/lib/checkbool.h @@ -39,8 +39,6 @@ class Token; /** @brief checks dealing with suspicious usage of boolean type (not for evaluating conditions) */ class CPPCHECKLIB CheckBool : public Check { - friend class TestFixture; - public: /** @brief This constructor is used when registering the CheckClass */ CheckBool() : Check(myName()) {} diff --git a/lib/checkboost.h b/lib/checkboost.h index 1aba5b6d5..a868463fe 100644 --- a/lib/checkboost.h +++ b/lib/checkboost.h @@ -38,8 +38,6 @@ class Token; /** @brief %Check Boost usage */ class CPPCHECKLIB CheckBoost : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckClass */ CheckBoost() : Check(myName()) {} diff --git a/lib/checkbufferoverrun.h b/lib/checkbufferoverrun.h index f83fd928b..7e90faf2d 100644 --- a/lib/checkbufferoverrun.h +++ b/lib/checkbufferoverrun.h @@ -57,9 +57,6 @@ class Token; * other function and pass a buffer and reads or writes too much data. */ class CPPCHECKLIB CheckBufferOverrun : public Check { - friend class TestBufferOverrun; - friend class TestFixture; - public: /** This constructor is used when registering the CheckClass */ CheckBufferOverrun() : Check(myName()) {} diff --git a/lib/checkcondition.h b/lib/checkcondition.h index d1e29574f..d0aba1b2d 100644 --- a/lib/checkcondition.h +++ b/lib/checkcondition.h @@ -48,8 +48,6 @@ namespace ValueFlow { */ class CPPCHECKLIB CheckCondition : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckAssignIf */ CheckCondition() : Check(myName()) {} diff --git a/lib/checkexceptionsafety.h b/lib/checkexceptionsafety.h index e0a56c440..5888a2c9f 100644 --- a/lib/checkexceptionsafety.h +++ b/lib/checkexceptionsafety.h @@ -45,8 +45,6 @@ class Token; */ class CPPCHECKLIB CheckExceptionSafety : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckClass */ CheckExceptionSafety() : Check(myName()) {} diff --git a/lib/checkfunctions.h b/lib/checkfunctions.h index a4cdd4fe8..537f8fe87 100644 --- a/lib/checkfunctions.h +++ b/lib/checkfunctions.h @@ -49,9 +49,6 @@ namespace ValueFlow { */ class CPPCHECKLIB CheckFunctions : public Check { - friend class TestFunctions; - friend class TestFixture; - public: /** This constructor is used when registering the CheckFunctions */ CheckFunctions() : Check(myName()) {} diff --git a/lib/checkinternal.h b/lib/checkinternal.h index 823d3d2f5..2ce0a2649 100644 --- a/lib/checkinternal.h +++ b/lib/checkinternal.h @@ -39,7 +39,6 @@ class Token; /** @brief %Check Internal cppcheck API usage */ class CPPCHECKLIB CheckInternal : public Check { - friend class TestFixture; public: /** This constructor is used when registering the CheckClass */ CheckInternal() : Check(myName()) {} diff --git a/lib/checkleakautovar.h b/lib/checkleakautovar.h index 8b44b915e..a6b2908af 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -107,8 +107,6 @@ public: */ class CPPCHECKLIB CheckLeakAutoVar : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckLeakAutoVar */ CheckLeakAutoVar() : Check(myName()) {} diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index 1786f9804..81debae4c 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -48,7 +48,6 @@ namespace tinyxml2 { class CPPCHECKLIB CheckNullPointer : public Check { friend class TestNullPointer; - friend class TestFixture; public: /** @brief This constructor is used when registering the CheckNullPointer */ diff --git a/lib/checkother.h b/lib/checkother.h index b1969a47d..701b90090 100644 --- a/lib/checkother.h +++ b/lib/checkother.h @@ -50,7 +50,6 @@ class CPPCHECKLIB CheckOther : public Check { friend class TestCharVar; friend class TestIncompleteStatement; friend class TestOther; - friend class TestFixture; public: /** @brief This constructor is used when registering the CheckClass */ diff --git a/lib/checksizeof.h b/lib/checksizeof.h index e738c8fce..eaf395c21 100644 --- a/lib/checksizeof.h +++ b/lib/checksizeof.h @@ -39,8 +39,6 @@ class Token; /** @brief checks on usage of sizeof() operator */ class CPPCHECKLIB CheckSizeof : public Check { - friend class TestFixture; - public: /** @brief This constructor is used when registering the CheckClass */ CheckSizeof() : Check(myName()) {} diff --git a/lib/checkstl.h b/lib/checkstl.h index dffacfe8b..d518d2d4d 100644 --- a/lib/checkstl.h +++ b/lib/checkstl.h @@ -43,8 +43,6 @@ class ErrorLogger; /** @brief %Check STL usage (invalidation of iterators, mismatching containers, etc) */ class CPPCHECKLIB CheckStl : public Check { - friend class TestFixture; - public: /** This constructor is used when registering the CheckClass */ CheckStl() : Check(myName()) {} diff --git a/lib/checkstring.h b/lib/checkstring.h index 0b2cb4ac2..c91192430 100644 --- a/lib/checkstring.h +++ b/lib/checkstring.h @@ -39,8 +39,6 @@ class Token; /** @brief Detect misusage of C-style strings and related standard functions */ class CPPCHECKLIB CheckString : public Check { - friend class TestFixture; - public: /** @brief This constructor is used when registering the CheckClass */ CheckString() : Check(myName()) {} diff --git a/lib/checktype.h b/lib/checktype.h index dcab41b52..ae99cffc4 100644 --- a/lib/checktype.h +++ b/lib/checktype.h @@ -42,8 +42,6 @@ class ValueType; /** @brief Various small checks */ class CPPCHECKLIB CheckType : public Check { - friend class TestFixture; - public: /** @brief This constructor is used when registering the CheckClass */ CheckType() : Check(myName()) {} diff --git a/lib/checkunusedfunctions.h b/lib/checkunusedfunctions.h index 762300ccf..dc834f96a 100644 --- a/lib/checkunusedfunctions.h +++ b/lib/checkunusedfunctions.h @@ -44,8 +44,6 @@ namespace CTU { /// @{ class CPPCHECKLIB CheckUnusedFunctions : public Check { - friend class TestUnusedFunctions; - public: /** @brief This constructor is used when registering the CheckUnusedFunctions */ CheckUnusedFunctions() : Check(myName()) {} diff --git a/lib/checkvaarg.h b/lib/checkvaarg.h index 2284e2bff..bfeec28f9 100644 --- a/lib/checkvaarg.h +++ b/lib/checkvaarg.h @@ -40,8 +40,6 @@ class Token; */ class CPPCHECKLIB CheckVaarg : public Check { - friend class TestFixture; - public: CheckVaarg() : Check(myName()) {} diff --git a/test/fixture.h b/test/fixture.h index 050e7c91e..6ec0c83f1 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -127,7 +127,7 @@ protected: template static void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) { - T& check = getCheck(); + Check& check = getCheck(); check.runChecks(tokenizer, errorLogger); } diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index b5361335b..30f985f97 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -4966,7 +4966,8 @@ private: void getErrorMessages() { // Ticket #2292: segmentation fault when using --errorlist - getCheck().getErrorMessages(this, nullptr); + const Check& c = getCheck(); + c.getErrorMessages(this, nullptr); } void arrayIndexThenCheck() { @@ -5161,9 +5162,9 @@ private: // Check code.. std::list fileInfo; - CheckBufferOverrun checkBO(&tokenizer, &settings0, this); - fileInfo.push_back(checkBO.getFileInfo(&tokenizer, &settings0)); - checkBO.analyseWholeProgram(ctu, fileInfo, settings0, *this); + Check& c = getCheck(); + fileInfo.push_back(c.getFileInfo(&tokenizer, &settings0)); + c.analyseWholeProgram(ctu, fileInfo, settings0, *this); while (!fileInfo.empty()) { delete fileInfo.back(); fileInfo.pop_back(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 5413a56c1..8ee7462b6 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8777,7 +8777,7 @@ private: void ctu(const std::vector &code) { const Settings settings; - auto &check = getCheck(); + Check &check = getCheck(); // getFileInfo std::list fileInfo; @@ -8835,9 +8835,8 @@ private: ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line); // Check.. - CheckClass checkClass(&tokenizer, &settings1, this); - - Check::FileInfo * fileInfo = (checkClass.getFileInfo)(&tokenizer, &settings1); + const Check& c = getCheck(); + Check::FileInfo * fileInfo = (c.getFileInfo)(&tokenizer, &settings1); delete fileInfo; } diff --git a/test/testio.cpp b/test/testio.cpp index 4db7e72e4..0cd148edb 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -102,13 +102,12 @@ private: ASSERT_LOC(tokenizer.tokenize(istr, file_in.c_str()), file, line); // Check.. - CheckIO checkIO(&tokenizer, &settings1, this); - checkIO.checkWrongPrintfScanfArguments(); - if (!onlyFormatStr) { - checkIO.checkCoutCerrMisusage(); - checkIO.checkFileUsage(); - checkIO.invalidScanf(); + if (onlyFormatStr) { + CheckIO checkIO(&tokenizer, &settings1, this); + checkIO.checkWrongPrintfScanfArguments(); + return; } + runChecks(tokenizer, this); } void coutCerrMisusage() { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 7da0da44c..2c116825e 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -4412,9 +4412,9 @@ private: // Check code.. std::list fileInfo; - CheckNullPointer checkNullPointer(&tokenizer, &settings, this); - fileInfo.push_back(checkNullPointer.getFileInfo(&tokenizer, &settings)); - checkNullPointer.analyseWholeProgram(ctu, fileInfo, settings, *this); + Check& c = getCheck(); + fileInfo.push_back(c.getFileInfo(&tokenizer, &settings)); + c.analyseWholeProgram(ctu, fileInfo, settings, *this); while (!fileInfo.empty()) { delete fileInfo.back(); fileInfo.pop_back(); diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index c8b02fca4..c0c49b1d4 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -7371,9 +7371,9 @@ private: // Check code.. std::list fileInfo; - CheckUninitVar check(&tokenizer, &settings, this); - fileInfo.push_back(check.getFileInfo(&tokenizer, &settings)); - check.analyseWholeProgram(ctu, fileInfo, settings, *this); + Check& c = getCheck(); + fileInfo.push_back(c.getFileInfo(&tokenizer, &settings)); + c.analyseWholeProgram(ctu, fileInfo, settings, *this); while (!fileInfo.empty()) { delete fileInfo.back(); fileInfo.pop_back();