Skip to content

refs #14498 - do not create static instances of the checks#8555

Draft
firewave wants to merge 1 commit into
cppcheck-opensource:mainfrom
firewave:inst
Draft

refs #14498 - do not create static instances of the checks#8555
firewave wants to merge 1 commit into
cppcheck-opensource:mainfrom
firewave:inst

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator Author

Since we switched to non-OBJECT library everything which links against lib will instantiate all checks even if never used (i.e. dmake). This changes the code only instantiate them if they are actually requested.

As a follow-up we can stop relying on the global check instances in the tests and use local ones instead. As a final step this will (hopefully) finally allow us to land #5323.

Comment thread lib/check.h
Check& operator=(const Check &) = delete;

/** List of registered check classes. This is used by Cppcheck to run checks and generate documentation */
static std::list<Check *> &instances();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As another positive side effect this no longer needs to return a mutable reference.

Comment thread test/testcheck.cpp

private:
void run() override {
TEST_CASE(instancesSorted);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As we now have a fixed order of the checks there no longer is any reason to sort them.

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.

1 participant