Skip to content

[clang-format] Incorrectly merged empty records with default config #154796

@itzexpoexpo

Description

@itzexpoexpo

During PR #154580 we noticed that empty records (struct,union,class) get incorrectly merged by clang-format running on default config:

struct foo {};
struct bar {
  int i;
};

This happens even with BreakBeforeBraces: Custom and BraceWrapping.SplitEmptyRecord: true.
Expected output in both cases is:

struct foo {
};
struct bar {
  int i;
};

Behavior is correct if BraceWrapping.AfterStruct: true:

struct foo
{
};
struct bar
{
  int i;
};

Occurs at least since version 12.0.0 and is likely an issue in LineJoiner::tryFitMultipleLinesInOne or it's callees.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions