[llvm-bugs] [Bug 35106] New: BreakBeforeBraces and AllowShortBlocksOnASingleLine interferrs with each other

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 27 04:29:23 PDT 2017


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

            Bug ID: 35106
           Summary: BreakBeforeBraces and AllowShortBlocksOnASingleLine
                    interferrs with each other
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm-bugs at skybert.org
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

This works as expected:
---
Language:        Cpp
BasedOnStyle: LLVM
AllowShortBlocksOnASingleLine: true
AllowShortLoopsOnASingleLine: true
...

int code(std::vector<int> vec) {
  int count;
  for (auto &el : vec) count++;
  for (auto &el : vec) { count++; }
  for (auto &el : vec) {
    count++;
    break;
  }
}

This too:
---
Language:        Cpp
BasedOnStyle: LLVM
AllowShortLoopsOnASingleLine: true
BreakBeforeBraces: Allman
...

int code(std::vector<int> vec)
{
  int count;
  for (auto &el : vec) count++;
  for (auto &el : vec)
  {
    count++;
  }
  for (auto &el : vec)
  {
    count++;
    break;
  }
}

Combining these do not work:
---
Language:        Cpp
BasedOnStyle: LLVM
AllowShortBlocksOnASingleLine: true
AllowShortLoopsOnASingleLine: true
BreakBeforeBraces: Allman
...

int code(std::vector<int> vec)
{
  int count;
  for (auto &el : vec) count++;
  for (auto &el : vec) {
    count++;
  }
  for (auto &el : vec) {
    count++;
    break;
  }
}

Two errors:
1) All braces on ControlStatements are pulled up instead of following Allman.
2) 'ShortBlock's aren't made


Expected output:

int code(std::vector<int> vec)
{
  int count;
  for (auto &el : vec) count++;
  for (auto &el : vec) { count++; }
  for (auto &el : vec)
  {
    count++;
    break;
  }
}

-- 
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/20171027/71c8d116/attachment.html>


More information about the llvm-bugs mailing list