[clang-format] formatting changes when applied a second time
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
currently happening at HEAD (100077dbff5f) but same thing happens on an old v13.0.0 binary. this code snippet:
```cpp
// .clang-format file
// ---
// ContinuationIndentWidth: 8
// IndentWidth: 4
// ...
// $ clang-format --version
// clang-format version 22.0.0git (https://github.com/llvm/llvm-project.git 100077dbff5f24c4a4548d4859e5b4cff852512a)
struct foo {
void bar() {
{
{
{
{
{
FooTuple /* anothercomment */, FooInt /* comment */> baz;
}
}
}
}
}
}
};
```
run the first time results in
```cpp
struct foo {
void bar() {
{
{
{
{
{
FooTuple /* anothercomment
*/
,
FooInt /* comment */>
baz;
}
}
}
}
}
}
};
```
and the second and later runs settle on this instead:
```cpp
struct foo {
void bar() {
{
{
{
{
{
FooTuple<
FooInt /* anothercomment
*/
,
FooInt /* comment */>
baz;
}
}
}
}
}
}
};
```
Contributor guide
Research direction
Start with the provided .clang-format settings and C++ snippet, then run clang-format twice on the same input and compare the outputs. Trace the formatting behavior responsible for the changed second-pass layout, and consider the issue done when repeated runs produce identical output for this reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100