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

Look at flipping clang-tidy's misc-* to enable-by-default #4699

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Dec 17, 2024

I was wondering, instead of treating misc differently and enabling specific checks, maybe we can flip that since we actually seem okay with most of the checks?

The main check I'm enabling, with significant edits here, is misc-no-recursion. But maybe this is helpful to enable, even with the necessary NOLINTs, since we want to avoid recursion in the toolchain? This PR shows some example fixes in subst.cpp (which are more stylistic, since the code shouldn't actually have recursed due to its structure; I think we could remove the warning on TryResolveInst the same way). Some also just don't seem worth fixing, like those in tests files (I didn't see a way to exclude files in .clang-tidy, so instead I'm using NOLINTBEGIN). But I think we might actually want to fix inst_namer, and there's enough in convert that I didn't look closely.

Also, I made some protected -> private style fixes based on misc-non-private-member-variables-in-classes (this is also how I noticed class Real versus struct Real). With node_stack, it looks like the protected wasn't even used. Per style, data members should be private outside tests. But since we can't trivially exclude protected members in tests, I'm turning it off -- I don't view it as offering enough benefit on the whole.

migrate_cpp issues are preexisting (I believe we just aren't monitoring it), but changes there make bazel build --config=clang-tidy -k //... work cleanly.

@jonmeow
Copy link
Contributor Author

jonmeow commented Dec 17, 2024

@zygoloid Particularly interested in your recursion thoughts here.

@jonmeow jonmeow removed the request for review from chandlerc December 17, 2024 18:57
common/command_line.h Outdated Show resolved Hide resolved
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
@jonmeow jonmeow enabled auto-merge December 17, 2024 21:03
Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

Just FYI, I like the direction, and the comments on the no-recursion bits seem pretty helpful.

@jonmeow jonmeow added this pull request to the merge queue Dec 17, 2024
@jonmeow
Copy link
Contributor Author

jonmeow commented Dec 17, 2024

Note, per discussion, I'll be looking more at misc-non-private-member-variables-in-classes but in a separate PR.

auto-merge was automatically disabled December 17, 2024 21:36

Pull Request is not mergeable

Merged via the queue into carbon-language:trunk with commit 3f9a06a Dec 17, 2024
8 checks passed
@jonmeow jonmeow deleted the clang-tidy-misc branch December 17, 2024 21:39
github-merge-queue bot pushed a commit that referenced this pull request Dec 19, 2024
…to match (#4702)

Pursuant to discussion regarding #4699, turn on
`misc-non-private-member-variables-in-classes` using the
`IgnoreClassesWithAllMemberVariablesBeingPublic` flag (the check treats
structs as classes, so we need this for structs with all-public
members). Updates the style guide notes to match, which should be pretty
minor due to the scoping of test fixtures.

Also fixes some underscore uses in test files on the way. Basically this
is keeping the style for [class data member
naming](https://google.github.io/styleguide/cppguide.html#Variable_Names)
even while making them public.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants