Skip to content

[clang-format] formatting changes when applied a second time #173081

@joelhock

Description

@joelhock

currently happening at HEAD (100077d) but same thing happens on an old v13.0.0 binary. this code snippet:

// .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<FooInt<unsigned char, 2 /* commentabcde */> /* anothercomment */, FooInt<uint8_t, 0> /* comment */> baz;
}
}
}
}
}
}
};

run the first time results in

struct foo {
    void bar() {
        {
            {
                {
                    {
                        {
                            FooTuple<FooInt<unsigned char,
                                            2 /* commentabcde */> /* anothercomment
                                                                   */
                                     ,
                                     FooInt<uint8_t, 0> /* comment */>
                                    baz;
                        }
                    }
                }
            }
        }
    }
};

and the second and later runs settle on this instead:

struct foo {
    void bar() {
        {
            {
                {
                    {
                        {
                            FooTuple<
                                    FooInt<unsigned char,
                                           2 /* commentabcde */> /* anothercomment
                                                                  */
                                    ,
                                    FooInt<uint8_t, 0> /* comment */>
                                    baz;
                        }
                    }
                }
            }
        }
    }
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions