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-format] Multiline C macros gets aggressively indentations after formatting. #82426

Open
mingmingl-llvm opened this issue Feb 20, 2024 · 1 comment

Comments

@mingmingl-llvm
Copy link
Contributor

mingmingl-llvm commented Feb 20, 2024

This is the clang-format diff from the pre-commit CI of a pull request. The automatic formatted lines ( line 210 to line 267, line 284 to line 404, code between 780 to 970, etc) are indented in a way that’s hard to read at least for me.

Using // clang-format off and // clang-format on selectively around code regions (as demonstrated in a draft pr is one option. But it goes in the opposite of the good direction to enable clang-formats everywhere.

File this bug to track the issue.

@mingmingl-llvm
Copy link
Contributor Author

Also is it a known problem that clang-format cannot format C macros perfectly given there is an option (https://clang.llvm.org/docs/ClangFormatStyleOptions.html#skipmacrodefinitionbody) to skip formatting them

mingmingl-llvm added a commit that referenced this issue Feb 21, 2024
…matting on the rest (#82057)

Without this, each time `InstrProfData.inc` is modified (like in
#81691), pre-commit CI
clang-format aggressively formats many lines in an unreadable way. Pull
request with red pre-commit checks are usually frowned upon.

* Use `// clang-format:<reason>` instead of `/* clang-format */`. The
former
[allows](https://github.com/llvm/llvm-project/blob/563ef306017a47d387f1c36dd562b172c1ad0626/clang/lib/Format/Format.cpp#L4108-L4113)
specifying a reason but the latter is
[not](https://github.com/llvm/llvm-project/blob/563ef306017a47d387f1c36dd562b172c1ad0626/clang/lib/Format/Format.cpp#L4105-L4106).
- Filed #82426 to track the
issue in clang-format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant