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] Misaligned trailing comments in the presence of an empty block comment #53441

Closed
mkurdej opened this issue Jan 27, 2022 · 3 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior clang-format

Comments

@mkurdej
Copy link
Member

mkurdej commented Jan 27, 2022

That's a minor issue.

With LLVM style, alignment of comments is off if there's an empty block comment at the beginning of the line.
Minimal repro:

/**/     //
int a; //

Expected:

/**/   //
int a; //

Mind, formatting is fine if there's at least a single character in the block comment.

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

llvmbot commented Jan 27, 2022

@llvm/issue-subscribers-bug

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 27, 2022

@llvm/issue-subscribers-clang-format

@mkurdej mkurdej self-assigned this Jan 28, 2022
@mkurdej
Copy link
Member Author

mkurdej commented Jan 28, 2022

Revision URI: https://reviews.llvm.org/D118475

@mkurdej mkurdej added the awaiting-review Has pending Phabricator review label Jan 28, 2022
@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Jan 28, 2022
arichardson pushed a commit to CTSRD-CHERI/llvm-project that referenced this issue Jan 3, 2023
… empty block comment.

Fixes llvm/llvm-project#53441.

Expected code:
```
/**/   //
int a; //
```

was before misformatted to:
```
/**/     //
int a; //
```

Because the "remaining length" (after the starting `/*`) of an empty block comment `/**/` was computed to be 0 instead of 2.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D118475
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
Projects
None yet
Development

No branches or pull requests

2 participants