[llvm-bugs] [Bug 49722] New: AllowShortBlocksOnASingleLine not working for else blocks

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 25 04:19:20 PDT 2021


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

            Bug ID: 49722
           Summary: AllowShortBlocksOnASingleLine not working for else
                    blocks
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ichglaubeich at kommespaeter.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Clang-format configuration:
AllowShortBlocksOnASingleLine: Empty,
AllowShortIfStatementsOnASingleLine: false,
BreakBeforeBraces: Custom,
BraceWrapping: { AfterControlStatement: Always, BeforeElse: true, },


Formatted part of code:

// BEFORE
if (true)
{}
else
{}

// AFTER
if (true) {}
else
{}

// EXPECTED
if (true) {}
else {}

if (true)
{
    ;
}
else {}

if (true) {}
else
{
    ;
}


Is there a way to move the bracket from below to right after the else, like
it's done for the if? Is this a bug? I was hoping that's what
"AllowShortBlocksOnASingleLine: Empty" implies and tried almost all values of
the BreakBeforeBraces property but couldn't get the desired effect.

-- 
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/20210325/5e3cd0cd/attachment.html>


More information about the llvm-bugs mailing list