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] Forced line-break in pre-processor statements #123382

Open
tl-photography opened this issue Jan 17, 2025 · 1 comment
Open

[clang-format] Forced line-break in pre-processor statements #123382

tl-photography opened this issue Jan 17, 2025 · 1 comment

Comments

@tl-photography
Copy link

Lets assume we have this PP directive:

#if ((CONDITION_A_SWITCH == ENABLED) || (CONDITION_A_SWITCH == ENABLED) || (CONDITION_A_SWITCH == ENABLED))
[...]
#endif

It would be nice to configure clang-format in a way that I would format this like:

#if (   (CONDITION_A_SWITCH == ENABLED) \
     || (CONDITION_A_SWITCH == ENABLED) \
     || (CONDITION_A_SWITCH == ENABLED) )
[...]
#endif

The advantage of this would be that when SCM is used and lines would be added or removed, less or at least easier conflicts would occur.

In a large code base with a lot of feature switches, this would be very helpful.

I have checked the code if I could file a PR myself, but tbh I didn't find a place to start.

@tl-photography tl-photography changed the title Forced line-break in pre-processor statements [clang-format] Forced line-break in pre-processor statements Jan 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/issue-subscribers-clang-format

Author: None (tl-photography)

Lets assume we have this PP directive:
#if ((CONDITION_A_SWITCH == ENABLED) || (CONDITION_A_SWITCH == ENABLED) || (CONDITION_A_SWITCH == ENABLED))
[...]
#endif

It would be nice to configure clang-format in a way that I would format this like:

#if (   (CONDITION_A_SWITCH == ENABLED) \
     || (CONDITION_A_SWITCH == ENABLED) \
     || (CONDITION_A_SWITCH == ENABLED) )
[...]
#endif

The advantage of this would be that when SCM is used and lines would be added or removed, less or at least easier conflicts would occur.

In a large code base with a lot of feature switches, this would be very helpful.

I have checked the code if I could file a PR myself, but tbh I didn't find a place to start.

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

3 participants