From 3fa0515253e65dd309c9f4a768a1fc5bb83a801b Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Wed, 12 Jun 2024 23:25:40 +0200 Subject: [PATCH] Fix --- lib/checkunusedfunctions.cpp | 4 +++- test/testunusedfunctions.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 8310dafaa1f..3fc19d340d7 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -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); diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 0faae42bc03..8f18a33adfc 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -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() {