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 some problems and suggestions found by clang-tidy #4237

Merged
merged 14 commits into from
Nov 13, 2023

Conversation

vlstill
Copy link
Contributor

@vlstill vlstill commented Nov 9, 2023

All these are found by the clang-tidy static analyzer. At this point, I've been only running in on the headers as this is mainly a byproduct of linting a downstream tool. Some of these changes are in the readability category rather than possible bugs, but I think they are all worth applying.

@vlstill vlstill marked this pull request as draft November 10, 2023 08:09
@vlstill vlstill force-pushed the lint-1 branch 3 times, most recently from 55f5ebb to a4e4f0f Compare November 10, 2023 09:14
@vlstill vlstill marked this pull request as ready for review November 10, 2023 13:43
Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

Any chance we can make this a part of our CMake setup? Ideally, we can run clang-tidy checks as part of CI/ or just apply fix-its automatically. We can tweak the .clang-tidy file as needed.

@@ -51,11 +51,14 @@ struct StringRef {
len = 0;
}
StringRef(const StringRef &a) : p(a.p), len(a.len) {}
// avoid clang-tidy complaining
// NOLINTBEGIN(bugprone-unhandled-self-assignment)
Copy link
Collaborator

Choose a reason for hiding this comment

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

    if(this == &a)
      return *this;

instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is safe to be performed, I'm not sure if the if is worth having in such cases. If the if is there, one would have to wonder why it is needed.

@vlstill vlstill merged commit e624f7a into p4lang:main Nov 13, 2023
13 checks passed
@vlstill vlstill deleted the lint-1 branch November 13, 2023 11:08
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.

2 participants