Skip to content

BreakBeforeBraces: GNU should break before open brace of lambda #133135

Closed
@tromey

Description

@tromey

I work on a GNU-style code base that uses C++. My test config uses BreakBeforeBraces: GNU because it seems impossible to replicate real GNU-style behavior with BreakBeforeBraces: Custom (in particular conditionally applying IndentBraces).

I think this setting should cause a line break before the { of a lambda.

Test code:

int f(int y) {
  auto x = [&]() {
    for (int i = 0; i < y; ++i)
      return 97;
  };
  return x();
}

clang-format config:

BreakBeforeBraces: GNU

Actual output:

int f(int y)
{
  auto x = [&]() {
    for (int i = 0; i < y; ++i)
      return 97;
  };
  return x();
}

Expected output:

int f(int y)
{
  auto x = [&]()
    {
      for (int i = 0; i < y; ++i)
	return 97;
    };
  return x();
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions