llvm / llvm/llvm-project

[clang-format] Alignment of consecutive comments

Open
#209,189 3 comments 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

With clang-format version 22.1.8, I obtain:

```
struct hissqlite {
char *path; /* SQLite database file path. */
struct history *history; /* For his_seterror(). */
sqlite3 *db;
int flags; /* HIS_RDONLY / HIS_RDWR / ... */
};
```

instead of what I would have expected:

```
struct hissqlite {
char *path; /* SQLite database file path. */
struct history *history; /* For his_seterror(). */
sqlite3 *db;
int flags; /* HIS_RDONLY / HIS_RDWR / ... */
};
```

Maybe it is an option I have overlooked (though I do not see one in `AlignTrailingComments` which would do that). I think the default would be to align the last comment with the two other ones.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the result with clang-format 22.1.8 using the struct example in the issue. Then inspect how the AlignTrailingComments option handles consecutive comments; the work is done when the final comment aligns with the preceding comments as shown in the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.