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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,11 +1425,11 @@ void CheckClassImpl::privateFunctions()
}
}

void CheckClassImpl::unusedPrivateFunctionError(const Token* tok1, const Token *tok2, const std::string &classname, const std::string &funcname)
void CheckClassImpl::unusedPrivateFunctionError(const Token* tokImpl, const Token *tokDef, const std::string &classname, const std::string &funcname)
{
std::list<const Token *> toks{ tok1 };
if (tok2)
toks.push_front(tok2);
std::list<const Token *> toks{ tokDef };
if (tokDef != tokImpl)
toks.push_back(tokImpl);
reportError(toks, Severity::style, "unusedPrivateFunction", "$symbol:" + classname + "::" + funcname + "\nUnused private function: '$symbol'", CWE398, Certainty::normal);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CPPCHECKLIB CheckClassImpl : public CheckImpl {
void uninitVarError(const Token *tok, const std::string &classname, const std::string &varname);
void missingMemberCopyError(const Token *tok, FunctionType functionType, const std::string& classname, const std::string& varname);
void operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive);
void unusedPrivateFunctionError(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname);
void unusedPrivateFunctionError(const Token *tokImpl, const Token *tokDef, const std::string &classname, const std::string &funcname);
void memsetError(const Token *tok, const std::string &memfunc, const std::string &classname, const std::string &type, bool isContainer = false);
void memsetErrorReference(const Token *tok, const std::string &memfunc, const std::string &type);
void memsetErrorFloat(const Token *tok, const std::string &type);
Expand Down
16 changes: 8 additions & 8 deletions test/testunusedprivfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class TestUnusedPrivateFunction : public TestFixture {
"Fred::Fred()\n"
"{}\n");

ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:6:12]: (style) Unused private function: 'Fred::get' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:6:12]: (style) Unused private function: 'Fred::get' [unusedPrivateFunction]\n", errout_str());
}


Expand Down Expand Up @@ -407,7 +407,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" C() = default;\n"
" void f() const { (void)this; }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:3:10] -> [test.cpp:3:10]: (style) Unused private function: 'C::f' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused private function: 'C::f' [unusedPrivateFunction]\n", errout_str());
}


Expand All @@ -424,7 +424,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" static void f()\n"
" { }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:10:17] -> [test.cpp:10:17]: (style) Unused private function: 'A::f' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:10:17]: (style) Unused private function: 'A::f' [unusedPrivateFunction]\n", errout_str());

check("class A\n"
"{\n"
Expand Down Expand Up @@ -460,7 +460,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" class I { I() = default; };\n"
" void f() const { (void)this; }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:3:10] -> [test.cpp:3:10]: (style) Unused private function: 'C::f' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:10]: (style) Unused private function: 'C::f' [unusedPrivateFunction]\n", errout_str());
}


Expand Down Expand Up @@ -501,7 +501,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" void foo() {}\n" // Skip for overrides of virtual functions of base
" void bar() {}\n" // Don't skip if no function is overridden
"};\n");
ASSERT_EQUALS("[test.cpp:9:10] -> [test.cpp:9:10]: (style) Unused private function: 'derived::bar' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:9:10]: (style) Unused private function: 'derived::bar' [unusedPrivateFunction]\n", errout_str());

check("class Base {\n"
"private:\n"
Expand Down Expand Up @@ -576,7 +576,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" friend Bar;\n"
" void f() { }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:5:10] -> [test.cpp:5:10]: (style) Unused private function: 'Foo::f' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:5:10]: (style) Unused private function: 'Foo::f' [unusedPrivateFunction]\n", errout_str());

check("struct F;\n" // #10265
"struct S {\n"
Expand Down Expand Up @@ -663,7 +663,7 @@ class TestUnusedPrivateFunction : public TestFixture {
" void startListening() {\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:8:10] -> [test.cpp:8:10]: (style) Unused private function: 'Fred::startListening' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:8:10]: (style) Unused private function: 'Fred::startListening' [unusedPrivateFunction]\n", errout_str());

// #5059
check("class Fred {\n"
Expand Down Expand Up @@ -813,7 +813,7 @@ class TestUnusedPrivateFunction : public TestFixture {
"};\n"
"int Foo::i = sth();\n"
"int i = F();\n");
ASSERT_EQUALS("[test.cpp:3:16] -> [test.cpp:3:16]: (style) Unused private function: 'Foo::F' [unusedPrivateFunction]\n", errout_str());
ASSERT_EQUALS("[test.cpp:3:16]: (style) Unused private function: 'Foo::F' [unusedPrivateFunction]\n", errout_str());
}

void templateSimplification() { //ticket #6183
Expand Down
Loading