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] Unnecessary space added before // clang-format on which disables formatting #53844

Closed
mkurdej opened this issue Feb 15, 2022 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior clang-format regression

Comments

@mkurdej
Copy link
Member

mkurdej commented Feb 15, 2022

Using LLVM style, and given input:

// clang-format off
//comment
// clang-format on
int      unformatted;

clang-format adds a space before clang-format on:

// clang-format off
//comment
//  clang-format on
int unformatted;

So the line int unformatted; gets formatted this time but next time, // clang-format on does not enable the formatting and any code futher down is not formatted anymore.
E.g. if know I change the code to:

// clang-format off
//comment
//  clang-format on
int         unformatted_again;

it will stay as is (because of this additional space in // clang-format on).

@mkurdej mkurdej added bug Indicates an unexpected problem or unintended behavior clang-format labels Feb 15, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 15, 2022

@llvm/issue-subscribers-bug

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 15, 2022

@llvm/issue-subscribers-clang-format

@mkurdej
Copy link
Member Author

mkurdej commented Feb 15, 2022

That's a regression in clang-format 13. Version 12 was OK.

@mkurdej
Copy link
Member Author

mkurdej commented Feb 15, 2022

BTW, I thought that it could be worked around using:

SpacesInLineCommentPrefix:
  Minimum: 1
  Maximum: 1

but that doesn't change anything.

@penagos
Copy link
Member

penagos commented Feb 19, 2022

I've raised a review request for this at: https://reviews.llvm.org/D120188.
I believe this was a regression introduced by: https://reviews.llvm.org/D92257.

@mkurdej mkurdej added the awaiting-review Has pending Phabricator review label Feb 19, 2022
@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Feb 20, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
…irectives

Fixes llvm/llvm-project#53844.
I believe this regression was caused by not accounting for clang-format directives in https://reviews.llvm.org/D92257.

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D120188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior clang-format regression
Projects
None yet
Development

No branches or pull requests

3 participants