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

Upgrade to clang-format 19 #8543

Merged
merged 9 commits into from
Jan 2, 2025
Merged

Upgrade to clang-format 19 #8543

merged 9 commits into from
Jan 2, 2025

Conversation

alexreinking
Copy link
Member

Upgrade to clang-format 19 and apply the tool to the codebase. There are three main groups of changes:

  1. Reasonable tweaks to spacing around operators, applied automatically
  2. Manual line-breaks added to lambda arguments in the Python bindings
  3. Less reasonable tweaks to spacing around template parameter lists in IRMatch.h

I updated the .clang-format file to replace deprecated options with their supported counterparts. I also removed penalty tweaks that didn't do anything.

Clang format 19 is more willing to remove line breaks with ColumnLimit: 0 than before. It does a particularly bad job with lambda arguments (as can be seen in the Python bindings). I found it necessary to add a trailing comment to the last line of each lambda.

src/IRMatch.h Outdated
base.template match<bound | bindings<Vec>::mask>(v.slice_begin(), state) &&
stride.template match<bound | bindings<Vec>::mask | bindings<Base>::mask>(v.slice_stride(), state) &&
lanes.template match<bound | bindings<Vec>::mask | bindings<Base>::mask | bindings<Stride>::mask>(v.type.lanes(), state);
base.template match < bound | bindings<Vec>::mask > (v.slice_begin(), state) &&
Copy link
Member

Choose a reason for hiding this comment

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

This is fine I guess, but I'm wondering if some parens would work, just in case it's something about bitwise or having lower precedence than a comparison like <

base.template match<(bound | bindings<Vec>::mask)>(v.slice_begin(), state)

Copy link
Member Author

Choose a reason for hiding this comment

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

It does like the parentheses better, and so do I

HALIDE_ALWAYS_INLINE
storage_T *
address_of(Args... args) const {
HALIDE_ALWAYS_INLINE storage_T *
Copy link
Member

Choose a reason for hiding this comment

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

imo if this is now two lines, it would be better with the return type on the second line instead of the first.

Copy link
Member Author

Choose a reason for hiding this comment

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

It wouldn't let me break there, but it seems happy with everything on one line, which is fine in this case. If I put a // break after HALIDE_ALWAYS_INLINE, it still insists on breaking after storage_T *.

@steven-johnson
Copy link
Contributor

Ready to land?

@alexreinking alexreinking merged commit 6b9f786 into main Jan 2, 2025
19 checks passed
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