llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.97k stars 11.54k forks source link

clang-format: Behavior changes between 16.0 and 17.0 #73584

Open LinZhihao-723 opened 9 months ago

LinZhihao-723 commented 9 months ago

Hi, when I update the clang-format from v16.0 to v17.0, the behavior of the following code block changes: Before (16.0):

    PyObjectPtr<PyObject> const readinto_method_obj{
            PyObject_GetAttrString(input_stream, "readinto")};

After (17.0):

    PyObjectPtr<PyObject> const readinto_method_obj{PyObject_GetAttrString(input_stream, "readinto")
    };

Is this an expected behavior? Is there any new settings I need to update to keep the old behavior, or at least sth like:

    PyObjectPtr<PyObject> const readinto_method_obj{
            PyObject_GetAttrString(input_stream, "readinto")
    };

Here is my clang-format config file: https://github.com/y-scope/clp-ffi-py/blob/main/.clang-format Thanks!

owenca commented 9 months ago

Bisected to 413a7cb6e0db. @gedare

gedare commented 9 months ago

This looks like it hits a known bug in the BlockIndent option: https://github.com/llvm/llvm-project/issues/55731

The bug appears now, because the object initializer here is being picked up for BlockIndent, and the line hits the column limit right at the closing bracket )}; We had a discussion about this on Phabricator. The documentation was clear that BlockIndented Cpp11BracedInitializers are treated as function calls. The way to fix this bug, is to fix #55731.