diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index c3930ea9bcf..6a00f33655f 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -30,7 +30,7 @@ noExplicitConstructor:externals/tinyxml2/tinyxml2.h missingOverride:externals/tinyxml2/tinyxml2.h invalidPrintfArgType_sint:externals/tinyxml2/tinyxml2.h naming-privateMemberVariable:externals/tinyxml2/tinyxml2.h -functionStatic:externals/tinyxml2/tinyxml2.h +functionStatic:externals/tinyxml2/tinyxml2.cpp invalidPrintfArgType_uint:externals/tinyxml2/tinyxml2.cpp funcArgNamesDifferent:externals/tinyxml2/tinyxml2.cpp nullPointerRedundantCheck:externals/tinyxml2/tinyxml2.cpp diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1e4e7fc5fde..a716128b01c 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2642,7 +2642,7 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st { std::list toks{ tok1 }; if (tok2) - toks.push_back(tok2); + toks.push_front(tok2); if (!suggestStatic) { const std::string msg = foundAllBaseClasses ? "Technically the member function '$symbol' can be const.\nThe member function '$symbol' can be made a const " : diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c6038fd90c8..aa8cd06302c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1786,6 +1786,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds() } } +// cppcheck-suppress functionConst - has side effects void SymbolDatabase::setArrayDimensionsUsingValueFlow() { // set all unknown array dimensions diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 705197e1fa0..7ffc1f19d65 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1412,7 +1412,7 @@ class CPPCHECKLIB SymbolDatabase { nonneg int sizeOfType(const Token *type) const; /** Set array dimensions when valueflow analysis is completed */ - void setArrayDimensionsUsingValueFlow(); // cppcheck-suppress functionConst // has side effects + void setArrayDimensionsUsingValueFlow(); void clangSetVariables(const std::vector &variableList); void createSymbolDatabaseExprIds(); @@ -1435,14 +1435,12 @@ class CPPCHECKLIB SymbolDatabase { void createSymbolDatabaseNeedInitialization(); void createSymbolDatabaseVariableSymbolTable(); void createSymbolDatabaseSetScopePointers(); - void createSymbolDatabaseSetFunctionPointers(bool firstPass); // cppcheck-suppress functionConst // has side effects + void createSymbolDatabaseSetFunctionPointers(bool firstPass); void createSymbolDatabaseSetVariablePointers(); - // cppcheck-suppress functionConst void createSymbolDatabaseSetTypePointers(); void createSymbolDatabaseSetSmartPointerType(); - void createSymbolDatabaseEnums(); // cppcheck-suppress functionConst // has side effects - void createSymbolDatabaseEscapeFunctions(); // cppcheck-suppress functionConst // has side effects - // cppcheck-suppress functionConst + void createSymbolDatabaseEnums(); + void createSymbolDatabaseEscapeFunctions(); void createSymbolDatabaseIncompleteVars(); void debugSymbolDatabase() const; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e2226269162..10ca8e7a352 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3839,6 +3839,7 @@ void Tokenizer::arraySize() } } +// cppcheck-suppress functionConst void Tokenizer::arraySizeAfterValueFlow() { // After ValueFlow, adjust array sizes. @@ -7087,6 +7088,7 @@ void Tokenizer::simplifyVarDecl(const bool only_k_r_fpar) simplifyVarDecl(list.front(), nullptr, only_k_r_fpar); } +// cppcheck-suppress functionConst - has side effects void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, const bool only_k_r_fpar) { const bool cpp = isCPP(); diff --git a/lib/tokenize.h b/lib/tokenize.h index cd2e299e47b..2a79be00efb 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -133,7 +133,7 @@ class CPPCHECKLIB Tokenizer { /** Insert array size where it isn't given */ void arraySize(); - void arraySizeAfterValueFlow(); // cppcheck-suppress functionConst + void arraySizeAfterValueFlow(); /** Simplify labels and 'case|default' syntaxes. */ @@ -165,7 +165,7 @@ class CPPCHECKLIB Tokenizer { * \param only_k_r_fpar Only simplify K&R function parameters */ void simplifyVarDecl( bool only_k_r_fpar); - void simplifyVarDecl(Token * tokBegin, const Token * tokEnd, bool only_k_r_fpar); // cppcheck-suppress functionConst // has side effects + void simplifyVarDecl(Token * tokBegin, const Token * tokEnd, bool only_k_r_fpar); /** * Simplify variable initialization diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 2c34abcc7d9..97c6f2d949f 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -665,9 +665,9 @@ namespace { class Fred : public QObject { Q_OBJECT private slots: - // cppcheck-suppress functionStatic void foo(); }; + // cppcheck-suppress functionStatic void Fred::foo() {} // bitfields14 @@ -816,7 +816,6 @@ struct DQObject_missingOverride : BQObject_missingOverride { namespace { class TestUnusedFunction : public QObject { // #13236 TestUnusedFunction(); - // cppcheck-suppress functionStatic void doStuff(); }; @@ -824,5 +823,6 @@ namespace { QObject::connect(this, SIGNAL(doStuff()), SLOT(doStuff())); } + // cppcheck-suppress functionStatic void TestUnusedFunction::doStuff() {} // Should not warn here with unusedFunction } \ No newline at end of file diff --git a/test/testclass.cpp b/test/testclass.cpp index 1d713461820..20ee4e4d947 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -3811,14 +3811,14 @@ class TestClass : public TestFixture { " int getA();\n" "};\n" "int Fred::getA() { return a; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::getA' can be const.\n", errout_str()); checkConst("class Fred {\n" " std::string s;\n" " const std::string & foo();\n" "};\n" "const std::string & Fred::foo() { return \"\"; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'Fred::foo' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (performance, inconclusive) Technically the member function 'Fred::foo' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); // functions with a function call to a non-const member can't be const.. (#1305) checkConst("class Fred\n" @@ -3854,7 +3854,7 @@ class TestClass : public TestFixture { " void foo(std::string & a);\n" "};\n" "void Fred::foo(std::string & a) { a = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); // assignment to variable can't be const checkConst("class Fred {\n" @@ -3870,7 +3870,7 @@ class TestClass : public TestFixture { " void foo(std::string & a, std::string & b);\n" "};\n" "void Fred::foo(std::string & a, std::string & b) { a = s; b = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3902,7 +3902,7 @@ class TestClass : public TestFixture { " void foo(int * a);\n" "};\n" "void Fred::foo(int * a) { *a = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3918,7 +3918,7 @@ class TestClass : public TestFixture { " void foo(std::string * a, std::string * b);\n" "};\n" "void Fred::foo(std::string * a, std::string * b) { *a = s; *b = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3954,8 +3954,8 @@ class TestClass : public TestFixture { "void Fred::foo() { }" "void Fred::foo(std::string & a) { a = s; }" "void Fred::foo(const std::string & a) { s = a; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'Fred::foo' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:7] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'Fred::foo' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:4] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout_str()); // check functions with different or missing parameter names checkConst("class Fred {\n" @@ -3971,11 +3971,11 @@ class TestClass : public TestFixture { "void Fred::foo3(int a, int b) { }\n" "void Fred::foo4(int a, int b) { }\n" "void Fred::foo5(int, int) { }"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'Fred::foo1' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:10] -> [test.cpp:4]: (performance, inconclusive) Technically the member function 'Fred::foo2' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:11] -> [test.cpp:5]: (performance, inconclusive) Technically the member function 'Fred::foo3' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:12] -> [test.cpp:6]: (performance, inconclusive) Technically the member function 'Fred::foo4' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:13] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'Fred::foo5' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:9]: (performance, inconclusive) Technically the member function 'Fred::foo1' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:4] -> [test.cpp:10]: (performance, inconclusive) Technically the member function 'Fred::foo2' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:5] -> [test.cpp:11]: (performance, inconclusive) Technically the member function 'Fred::foo3' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:6] -> [test.cpp:12]: (performance, inconclusive) Technically the member function 'Fred::foo4' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:7] -> [test.cpp:13]: (performance, inconclusive) Technically the member function 'Fred::foo5' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); // check nested classes checkConst("class Fred {\n" @@ -3993,7 +3993,7 @@ class TestClass : public TestFixture { " };\n" " int A::getA() { return a; }\n" "};"); - ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout_str()); checkConst("class Fred {\n" " class A {\n" @@ -4002,7 +4002,7 @@ class TestClass : public TestFixture { " };\n" "};\n" "int Fred::A::getA() { return a; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout_str()); // check deeply nested classes checkConst("class Fred {\n" @@ -4031,8 +4031,8 @@ class TestClass : public TestFixture { " };\n" " int B::getB() { return b; }\n" "};"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:9] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:11]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:7] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); checkConst("class Fred {\n" " class B {\n" @@ -4046,8 +4046,8 @@ class TestClass : public TestFixture { " int B::A::getA() { return a; }\n" " int B::getB() { return b; }\n" "};"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:10] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:11]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:7] -> [test.cpp:10]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); checkConst("class Fred {\n" " class B {\n" @@ -4061,8 +4061,8 @@ class TestClass : public TestFixture { "};\n" "int Fred::B::A::getA() { return a; }\n" "int Fred::B::getB() { return b; }"); - ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:11] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:7] -> [test.cpp:11]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n", errout_str()); } // operator< can often be const @@ -4846,7 +4846,7 @@ class TestClass : public TestFixture { " return m_iRealVal / m_d;\n" " return dRet;\n" "};"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'A::dGetValue' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'A::dGetValue' can be const.\n", errout_str()); } void const28() { // ticket #1883 @@ -5098,7 +5098,7 @@ class TestClass : public TestFixture { " };\n" "}\n" "int N::Base::getResourceName() { return var; }"); - ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:10]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); checkConst("namespace N\n" "{\n" @@ -5113,7 +5113,7 @@ class TestClass : public TestFixture { "{\n" " int Base::getResourceName() { return var; }\n" "}"); - ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); checkConst("namespace N\n" "{\n" @@ -5126,7 +5126,7 @@ class TestClass : public TestFixture { "}\n" "using namespace N;\n" "int Base::getResourceName() { return var; }"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:11]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout_str()); } void const36() { // ticket #2003 @@ -5311,7 +5311,7 @@ class TestClass : public TestFixture { "{\n" "}"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (performance, inconclusive) Technically the member function 'Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); checkConst("class Fred\n" "{\n" @@ -5325,7 +5325,7 @@ class TestClass : public TestFixture { "{\n" "}"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:9]: (performance, inconclusive) Technically the member function 'Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); checkConst("namespace NS {\n" " class Fred\n" @@ -5341,7 +5341,7 @@ class TestClass : public TestFixture { " }\n" "}"); - ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:8]: (performance, inconclusive) Technically the member function 'NS::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:10]: (performance, inconclusive) Technically the member function 'NS::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); checkConst("namespace NS {\n" " class Fred\n" @@ -5357,7 +5357,7 @@ class TestClass : public TestFixture { "{\n" "}"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (performance, inconclusive) Technically the member function 'NS::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:11]: (performance, inconclusive) Technically the member function 'NS::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); checkConst("class Foo {\n" " class Fred\n" @@ -5373,7 +5373,7 @@ class TestClass : public TestFixture { "{\n" "}"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (performance, inconclusive) Technically the member function 'Foo::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:11]: (performance, inconclusive) Technically the member function 'Foo::Fred::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); } void const43() { // ticket 2377 @@ -5673,7 +5673,7 @@ class TestClass : public TestFixture { "\n" " return RET_NOK;\n" "}"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (performance, inconclusive) Technically the member function 'A::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:9]: (performance, inconclusive) Technically the member function 'A::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); checkConst("class MyObject {\n" "public:\n" @@ -5844,7 +5844,7 @@ class TestClass : public TestFixture { " inherited::set(inherited::Key(key));\n" " }\n" "};\n", dinit(CheckConstOptions, $.inconclusive = false)); - ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (performance, inconclusive) Either there is a missing 'override', or the member function 'MixerParticipant::GetAudioFrame' can be static.\n", + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (performance, inconclusive) Either there is a missing 'override', or the member function 'MixerParticipant::GetAudioFrame' can be static.\n", errout_str()); } @@ -6130,7 +6130,7 @@ class TestClass : public TestFixture { "void S::f() {\n" " char* c = h->x[y];\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); } void const74() { // #10671 @@ -6195,7 +6195,7 @@ class TestClass : public TestFixture { "void S::f(const T* t) {\n" " const_cast(t)->e();\n" "};\n"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'S::f' can be static (but you may consider moving to unnamed namespace).\n", + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'S::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); } @@ -6272,10 +6272,10 @@ class TestClass : public TestFixture { "void S::n() {\n" " this->h();\n" "}\n"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (performance, inconclusive) Technically the member function 'S::g' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:14] -> [test.cpp:5]: (performance, inconclusive) Technically the member function 'S::h' can be static (but you may consider moving to unnamed namespace).\n" - "[test.cpp:17] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'S::k' can be const.\n" - "[test.cpp:21] -> [test.cpp:7]: (performance, inconclusive) Technically the member function 'S::m' can be static (but you may consider moving to unnamed namespace).\n", + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:11]: (performance, inconclusive) Technically the member function 'S::g' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:5] -> [test.cpp:14]: (performance, inconclusive) Technically the member function 'S::h' can be static (but you may consider moving to unnamed namespace).\n" + "[test.cpp:6] -> [test.cpp:17]: (style, inconclusive) Technically the member function 'S::k' can be const.\n" + "[test.cpp:7] -> [test.cpp:21]: (performance, inconclusive) Technically the member function 'S::m' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); } @@ -6494,7 +6494,7 @@ class TestClass : public TestFixture { "bool CheckB::f(const std::string& s) {\n" " return CheckA::test(s, mSettings, mTokenizer->isCPP());\n" "}\n"); - ASSERT_EQUALS("[test.cpp:20] -> [test.cpp:15]: (style, inconclusive) Technically the member function 'CheckB::f' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:15] -> [test.cpp:20]: (style, inconclusive) Technically the member function 'CheckB::f' can be const.\n", errout_str()); checkConst("void g(int&);\n" "struct S {\n" @@ -6608,7 +6608,7 @@ class TestClass : public TestFixture { " if (i && b)\n" " f(false);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:2]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); checkConst("struct S {\n" " void f(int& r);\n" @@ -6646,7 +6646,7 @@ class TestClass : public TestFixture { " if (b)\n" " f(false);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'C::f' can be static (but you may consider moving to unnamed namespace).\n", + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (performance, inconclusive) Technically the member function 'C::f' can be static (but you may consider moving to unnamed namespace).\n", errout_str()); } @@ -7331,7 +7331,7 @@ class TestClass : public TestFixture { " int func();\n" "};\n" "int B::func() { return b; }"); - ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout_str()); // base class has no virtual function checkConst("class A {\n" @@ -7357,7 +7357,7 @@ class TestClass : public TestFixture { " int func();\n" "};\n" "int B::func() { return b; }"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:11]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout_str()); // base class has virtual function checkConst("class A {\n" @@ -7442,9 +7442,9 @@ class TestClass : public TestFixture { " int func();\n" "};\n" "int C::func() { return c; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'A::func' can be const.\n" - "[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'B::func' can be const.\n" - "[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'A::func' can be const.\n" + "[test.cpp:12] -> [test.cpp:14]: (style, inconclusive) Technically the member function 'B::func' can be const.\n" + "[test.cpp:19] -> [test.cpp:21]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout_str()); // base class has virtual function checkConst("class A {\n" @@ -7534,9 +7534,9 @@ class TestClass : public TestFixture { " int getZ();\n" "};\n" "int Z::getZ() { return z; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n" - "[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n" - "[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n" + "[test.cpp:12] -> [test.cpp:14]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n" + "[test.cpp:19] -> [test.cpp:21]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout_str()); } void constIfCfg() { @@ -7679,7 +7679,7 @@ class TestClass : public TestFixture { "void S::f() {\n" " std::vector::const_iterator end = std.end();\n" "}\n", dinit(CheckConstOptions, $.s = &s)); - ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout_str()); } #define checkInitializerListOrder(...) checkInitializerListOrder_(__FILE__, __LINE__, __VA_ARGS__)