Skip to content
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

[clang-format] Misformatting with AlignAfterOpenBracket: BlockIndent #54808

Closed
sebhub opened this issue Apr 8, 2022 · 2 comments
Closed

[clang-format] Misformatting with AlignAfterOpenBracket: BlockIndent #54808

sebhub opened this issue Apr 8, 2022 · 2 comments
Labels
clang-format duplicate Resolved as duplicate

Comments

@sebhub
Copy link

sebhub commented Apr 8, 2022

The following code:

int function(int ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp)
{
  return ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp;
}

gets misformatted to:

int function(int ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
) {
  return ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp;
}

under .clang-format:

Language:        Cpp
AlignAfterOpenBracket: BlockIndent
ColumnLimit:     80

desired format:

int function(
  int ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
) {
  return ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp;
}

Tested that this bug occurs with clang-format 14.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2022

@llvm/issue-subscribers-clang-format

@Zingam
Copy link
Contributor

Zingam commented Nov 25, 2023

Despite that this issue is older than #55731 it is a duplicate. The other issue has more info and is linked to other duplicates.

@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Nov 25, 2023
@EugeneZelenko EugeneZelenko closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2023
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.
owenca added a commit that referenced this issue Jul 25, 2024
Fixes #55731

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing #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.

---------

Co-authored-by: Owen Pan <[email protected]>
yuxuanchen1997 pushed a commit that referenced this issue Jul 25, 2024
Summary:
Fixes #55731

The reported formatting problems were related to ignoring deep nesting
of "simple" functions (causing #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.

---------

Co-authored-by: Owen Pan <[email protected]>

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

4 participants