Skip to content

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

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

Closed
LinZhihao-723 opened this issue Nov 27, 2023 · 2 comments · Fixed by #108717
Closed

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

LinZhihao-723 opened this issue Nov 27, 2023 · 2 comments · Fixed by #108717

Comments

@LinZhihao-723
Copy link

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
Copy link
Contributor

owenca commented Nov 28, 2023

Bisected to 413a7cb. @gedare

@gedare
Copy link
Contributor

gedare commented Nov 30, 2023

This looks like it hits a known bug in the BlockIndent option:
#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.

gedare added a commit to gedare/llvm-project that referenced this issue May 23, 2024
Fixes llvm#55731
Fixes llvm#73584

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing llvm#54808) and to allowing the trailing
annotation to become separated from the closing parens, which allowed a
break to occur between the closing parens and the trailing annotation.
The fix for the nesting of "simple" functions is to detect them more
carefully. "Simple" was defined in a comment as being a single
non-expression argument. I tried to stay as close to the original intent
of the implementation while fixing the various bad formatting reports.

In the process of fixing these bugs, some latent bugs were discovered
related to how JavaScript Template Strings are handled. Those are also
fixed here.
gedare added a commit to gedare/llvm-project that referenced this issue Jul 10, 2024
Fixes llvm#55731
Fixes llvm#73584

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing llvm#54808) and to allowing the trailing
annotation to become separated from the closing parens, which allowed a
break to occur between the closing parens and the trailing annotation.
The fix for the nesting of "simple" functions is to detect them more
carefully. "Simple" was defined in a comment as being a single
non-expression argument. I tried to stay as close to the original intent
of the implementation while fixing the various bad formatting reports.

In the process of fixing these bugs, some latent bugs were discovered
related to how JavaScript Template Strings are handled. Those are also
fixed here.
gedare added a commit to gedare/llvm-project that referenced this issue Jul 23, 2024
Fixes llvm#55731
Fixes llvm#73584

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing llvm#54808) and to allowing the trailing
annotation to become separated from the closing parens, which allowed a
break to occur between the closing parens and the trailing annotation.
The fix for the nesting of "simple" functions is to detect them more
carefully. "Simple" was defined in a comment as being a single
non-expression argument. I tried to stay as close to the original intent
of the implementation while fixing the various bad formatting reports.

In the process of fixing these bugs, some latent bugs were discovered
related to how JavaScript Template Strings are handled. Those are also
fixed here.
gedare added a commit to gedare/llvm-project that referenced this issue Sep 14, 2024
@owenca owenca closed this as completed in df935ff Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants