Skip to content

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Sep 30, 2025

Change top-level and LLVM/MLIR/Clang .clang-format files to enforce Unix line ending.

Change top-level and LLVM/MLIR/Clang `.clang-format` files to
enforce unix line ending.
@jurahul jurahul marked this pull request as ready for review October 1, 2025 00:16
@jurahul
Copy link
Contributor Author

jurahul commented Oct 1, 2025

This is a follow on to the coding standard change and the discussion on https://discourse.llvm.org/t/llvm-source-file-line-endings/81388/16.

With this, folks attempting to commit C/C++ files with non-unix line endings will see a clang-format failure in GitHub CI. Currently enabling it for just clang/llvm/mlir projects, but if this seems reasonable and sticks, we can potentially incorporate it into the LLVM pre-defined style in clang-format.

@jurahul jurahul changed the title Enforce unix line endings for clang/llvm/mlir subdirectories Enforce unix line endings for Clang/LLVM/MLIR projects Oct 1, 2025
@jurahul jurahul requested a review from bogner October 1, 2025 00:20
@jurahul
Copy link
Contributor Author

jurahul commented Oct 1, 2025

@bogner to see if this is ok for a folks using Windows predominantly.

@jurahul jurahul changed the title Enforce unix line endings for Clang/LLVM/MLIR projects Enforce Unix line endings for Clang/LLVM/MLIR projects Oct 1, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM, but someone working on Windows should confirm. This will be good for the CI checks, but I'm not sure if this will negatively affect people's local checkouts.

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

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

Windows developer here, LGTM. I have most of my tree with \n line endings and haven't seen any negative impacts.

What happens to the files that specifically require \r\n endings for test purposes? Are these going to get mis-formatted/flagged as incorrect by clang-format?

@jurahul
Copy link
Contributor Author

jurahul commented Oct 1, 2025

Thanks for confirming that Windows side is fine. I assume clang-format runs only on C/C++ source files, so other files like .bat or .py should be unaffected by this change. Additionally, in my test PR #161257 I had modified a .cpp file under llvm/test and it did not complain, because llvm/test/.clang-format has DisableFormat: true. The same is true for clang/test/.clang-format. mlir/test does not have a .clang-format as the .cpp/.h file in there are true source files that are built as a part of the build and are not test inputs.

@jh7370
Copy link
Collaborator

jh7370 commented Oct 2, 2025

Thanks for confirming that Windows side is fine. I assume clang-format runs only on C/C++ source files, so other files like .bat or .py should be unaffected by this change. Additionally, in my test PR #161257 I had modified a .cpp file under llvm/test and it did not complain, because llvm/test/.clang-format has DisableFormat: true. The same is true for clang/test/.clang-format. mlir/test does not have a .clang-format as the .cpp/.h file in there are true source files that are built as a part of the build and are not test inputs.

Thanks, sounds good to me.

@jurahul jurahul merged commit 2ece31b into llvm:main Oct 2, 2025
12 checks passed
@jurahul jurahul deleted the clang_format_unix_line_end branch October 2, 2025 13:09
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
Change top-level and LLVM/MLIR/Clang `.clang-format` files to enforce
Unix line ending.
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