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

(clang-tidy): Enable static downcast and decl naming check #3709

Merged

Conversation

Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented Feb 9, 2022

Description

  • Enable a clang-tidy check to ensure we don't do static_cast for downcasting and always use dynamic_cast. This is safer, more likely to be correct, and most compilers will optimize them to be the same speed anyway if valid. There are no other changes to the codebase currently since we do it properly, but this check ensures the regression doesn't get introduced in a PR.
  • Also enables another check that looks for inconsistent naming between forward declarations and their implementations. This is unlikely to occur in the code base, but ensures no regressions get introduced.

Suggested changelog entry:

* Enable cppcoreguidelines-pro-type-static-cast-downcast and readability-inconsistent-declaration-parameter-name in clang-tidy.

@Skylion007 Skylion007 changed the title (clang-tidy): Enable static downcast check (clang-tidy): Enable static downcast and decl naming check Feb 9, 2022
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

Nice!

@henryiii henryiii merged commit 7f97581 into pybind:master Feb 9, 2022
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Feb 9, 2022
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Mar 29, 2022
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.

3 participants