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

attach-braces after enum doesn't, unless allowshortenums is true #48983

Open
adriaandegroot opened this issue Mar 19, 2021 · 1 comment
Open
Assignees
Labels
bugzilla Issues migrated from bugzilla clang-format

Comments

@adriaandegroot
Copy link

Bugzilla Link 49639
Version 11.0
OS FreeBSD
CC @lunasorcery

Extended Description

Reported by Luna on Twitter; she's stymied by the registration (e.g. real-name requirements) for the bug tracker. I can reproduce the problem.

This is an issue similar to #​46927 and possibly #​37302; there are a couple more attach-braces issues open as well. This is the input file:

enum EnumWithComma { A, B,
C,
};
enum EnumWithoutComma { A_, B_,
C_ };
struct Struct {
int a;
bool b;
} ;

When clang-format 11 (and 12, too) is used with attached braces and AllowShortEnumsOnASingleLine, it attaches braces but enums with trailing commas are somehow not "short".

$ clang-format11  --style="{Language: Cpp, BreakBeforeBraces: Attach, AllowShortEnumsOnASingleLine: true}" example.cpp
enum EnumWithComma {
  A,
  B,
  C,
};
enum EnumWithoutComma { A_, B_, C_ };
struct Struct {
  int a;
  bool b;
};

When clang-format 11 (and 12, too) is used with attached braces but short enums are not allowed on one line, it doesn't attach at all:

$ clang-format11  --style="{Language: Cpp, BreakBeforeBraces: Attach, AllowShortEnumsOnASingleLine: false}" example.cpp 
enum EnumWithComma
{
  A,
  B,
  C,
};
enum EnumWithoutComma
{
  A_,
  B_,
  C_
};
struct Struct {
  int a;
  bool b;
};

PS. Probably #​37302 and #​21200 can be closed, as they refer to ancient versions of clang-format and suitable configurations for brace-attachment and short enums (except for this bug) are available now.

@adriaandegroot
Copy link
Author

assigned to @lunasorcery

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
rettichschnidi added a commit to husqvarnagroup/zephyr that referenced this issue Jul 22, 2022
Even when BreakBeforeBraces is set to Linux, implying BraceWrapping for
AfterEnum to be true, clang-format version 12 puts the opening brace of
an enum declaration on a new line. [1]

One possible workaround would be to change AllowShortEnumsOnASingleLine
from false to true, but that would yield a different kind of unwanted
formatting.

clang-format version 13 and newer have this issue fixed, therefore
bumping the minimal version.

[1] llvm/llvm-project#48983

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
carlescufi pushed a commit to zephyrproject-rtos/zephyr that referenced this issue Aug 2, 2022
Even when BreakBeforeBraces is set to Linux, implying BraceWrapping for
AfterEnum to be true, clang-format version 12 puts the opening brace of
an enum declaration on a new line. [1]

One possible workaround would be to change AllowShortEnumsOnASingleLine
from false to true, but that would yield a different kind of unwanted
formatting.

clang-format version 13 and newer have this issue fixed, therefore
bumping the minimal version.

[1] llvm/llvm-project#48983

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
coreboot-org-bot pushed a commit to coreboot/zephyr-cros that referenced this issue Aug 4, 2022
Even when BreakBeforeBraces is set to Linux, implying BraceWrapping for
AfterEnum to be true, clang-format version 12 puts the opening brace of
an enum declaration on a new line. [1]

One possible workaround would be to change AllowShortEnumsOnASingleLine
from false to true, but that would yield a different kind of unwanted
formatting.

clang-format version 13 and newer have this issue fixed, therefore
bumping the minimal version.

[1] llvm/llvm-project#48983

(cherry picked from commit 8027072)

Original-Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
GitOrigin-RevId: 8027072
Change-Id: Iff7393129ab8c5b5cc10901dc31fb6d7e4c3a262
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/3806496
Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
Tested-by: CopyBot Service Account <copybot.service@gmail.com>
Tested-by: Fabio Baltieri <fabiobaltieri@google.com>
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
jeremybettis pushed a commit to jeremybettis/zephyr that referenced this issue Aug 4, 2022
Even when BreakBeforeBraces is set to Linux, implying BraceWrapping for
AfterEnum to be true, clang-format version 12 puts the opening brace of
an enum declaration on a new line. [1]

One possible workaround would be to change AllowShortEnumsOnASingleLine
from false to true, but that would yield a different kind of unwanted
formatting.

clang-format version 13 and newer have this issue fixed, therefore
bumping the minimal version.

[1] llvm/llvm-project#48983

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format
Projects
None yet
Development

No branches or pull requests

1 participant