[llvm-bugs] [Bug 43913] New: clang-format single line if impossible with braces

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 5 12:56:39 PST 2019


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

            Bug ID: 43913
           Summary: clang-format single line if impossible with braces
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mpozulp at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

If I build clang-format from tip of master and run it
using this .clang-format file

  AllowShortIfStatementsOnASingleLine: Always

it will change this single line if statement

  if (x) { x++; }

into this three line if statement

  if (x) {
    x++;
  }

How do I keep it as one line?

If I delete the braces it stays on one line, but the
style guide for the code I work on says the braces are
required. If I modify my .clang-format file to be

  AllowShortIfStatementsOnASingleLine: Always
  AllowShortBlocksOnASingleLine: Always

it stays on one line, but I don't want all short blocks
on a single line, just the if statement block. Any ideas?

-- 
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/20191105/383bc8db/attachment-0001.html>


More information about the llvm-bugs mailing list