[llvm-bugs] [Bug 25010] New: AllowShortIfStatementsOnASingleLine not working if an "else" statement is present

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 1 02:00:49 PDT 2015


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

            Bug ID: 25010
           Summary: AllowShortIfStatementsOnASingleLine not working if an
                    "else" statement is present
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lectem at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org
    Classification: Unclassified

With AllowShortIfStatementsOnASingleLine set to true, the following code

=================================

int foo()
{
    int var = 0;
    if(true)var++;
    else 
    {
        var--;
        printf("never happens\n");
    }
}

=================================

Is expected to give the following output :

=================================

int foo()
{
  int var = 0;
  if (true)var++;
  else
  {
    var--;
    printf("never happens\n");
  }
}

=================================

This is my .clang-format :

---
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: true


Note:
It would be nice if the rule applied to short "else" statements too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248983
91177308-0d34-0410-b5e6-96231b3b80d8

-- 
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/20151001/4caf0e10/attachment.html>


More information about the llvm-bugs mailing list