Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 12, 2024
1 parent 86837c5 commit 3fa0515
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const Setting
}

if (funcname) {
if (isRecursiveCall(funcname))
continue;
const auto baseName = stripTemplateParameters(funcname->str());
FunctionUsage &func = mFunctions[baseName];
const std::string& called_from_file = tokenizer.list.getFiles()[funcname->fileIndex()];

if (func.filename.empty() || func.filename == "+" || func.filename != called_from_file)
func.usedOtherFile = true;
else if (!isRecursiveCall(funcname))
else
func.usedSameFile = true;

mFunctionCalls.insert(baseName);
Expand Down
2 changes: 1 addition & 1 deletion test/testunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class TestUnusedFunctions : public TestFixture {
" if (cond) ;\n"
" else f1();\n"
"}");
ASSERT_EQUALS("[test.cpp:1]: (style) The function 'foo' is never used.\n", errout_str());
ASSERT_EQUALS("[test.cpp:1]: (style) The function 'f1' is never used.\n", errout_str());
}

void functionpointer() {
Expand Down

0 comments on commit 3fa0515

Please sign in to comment.