Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13236: False positive: unusedFunction reported when SLOT() is used in qt code #7270

Merged
merged 9 commits into from
Jan 30, 2025

Conversation

olabetskyi
Copy link
Collaborator

No description provided.

cfg/qt.cfg Outdated
<define name="SIGNAL(X)" value="#X"/>
<define name="SLOT(X)" value="#X"/>
<!-- <define name="SIGNAL(X)" value="#X"/> -->
<!-- <define name="SLOT(X)" value="#X"/> -->
Copy link
Collaborator

@chrchr-github chrchr-github Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this cause checkLibraryFunction warnings? Can we define value="X"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That's a good idea

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure if we want to mark these somehow to indicate that they are not function calls.. the testcode will be preprocessed to QObject::connect(this , doStuff(), doStuff());

Something like:

  <define name="SIGNAL(X)" value="__cppcheck__(X)"/>
  <define name="SLOT(X)" value="__cppcheck__(X)"/>

But imho we can implement that later if we see real problems with your SIGNAL/SLOT macros..

@danmar danmar merged commit 81f0086 into danmar:main Jan 30, 2025
60 checks passed
class TestUnusedFunction : public QObject { // #13236
TestUnusedFunction();
// cppcheck-suppress functionStatic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid this by adding (void)this to the body.

}

void TestUnusedFunction::doStuff() {} // Should not warn here with unusedFunction
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a method which triggers unusedFunction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants