Skip to content

AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine #47280

Closed
@jefftrull

Description

@jefftrull
Bugzilla Link 47936
Version 11.0
OS Linux
CC @KitsuneRal,@elvenfighter,@mydeveloperday

Extended Description

Using the MultiLine setting for BraceWrapping.AfterControlStatement appears to disable AllowShortFunctionsOnASingleLine, even in cases without any control statements. For the input:

void bar() {}
class Foo {
    void shortfunction() { bar(); }
};

The command:

clang-format --style="{BasedOnStyle: llvm, AllowShortFunctionsOnASingleLine: Inline, BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true, AfterControlStatement: MultiLine}}"

produces:

void bar() {}
class Foo {
  void shortfunction()
  {
    bar();
  }
};

If MultiLine is replaced with Always or Never, or is left out entirely, we get:

void bar() {}
class Foo {
  void shortfunction() { bar(); }
};

which is the expected result, as no control statements are present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions