[llvm-bugs] [Bug 52589] New: BraceWrapping.AfterControlStatement=Multiline breaks AllowShortFunctionsOnASingleLine setting

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 23 04:30:51 PST 2021


            Bug ID: 52589
           Summary: BraceWrapping.AfterControlStatement=Multiline breaks
                    AllowShortFunctionsOnASingleLine setting
           Product: clang
           Version: 13.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kyrylo.bohdanenko at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Consider the following C++ source file (test.cpp):

int theAnswer() { return 42; }

And the following clang-format configuration (.clang-format):

  Language: Cpp
  BreakBeforeBraces: Custom
    AfterFunction: true
    AfterControlStatement: MultiLine
  AllowShortFunctionsOnASingleLine: All

Note: this configuration is supposed to wrap the opening curly brace for
non-trivial-functions but allow for one-liners.

Then run clang-format like this:

clang-format -style=file test.cpp

Produced output:

int theAnswer()
  return 42;

Expected output: <same as input>

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/20211123/f34eb11f/attachment.html>

More information about the llvm-bugs mailing list