[llvm-bugs] [Bug 47936] New: AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 21 09:23:25 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47936

            Bug ID: 47936
           Summary: AfterControlStatement: MultiLine breaks
                    AllowShortFunctionsOnASingleLine
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: edaskel at att.net
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201021/4d50e755/attachment.html>


More information about the llvm-bugs mailing list