[llvm-bugs] [Bug 37302] New: One-line enum problem

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 1 03:51:40 PDT 2018


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

            Bug ID: 37302
           Summary: One-line enum problem
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mxcpin at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Configuration of clang-format:
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
BreakBeforeBraces: Custom
BraceWrapping: { AfterControlStatement: true, AfterEnum: true }

Code:

// BEFORE:
enum Enum { No, Yes };
if (statement) { doSomething(); }

// AFTER:
enum Enum
{
  No,
  Yes
};
if (statement) { doSomething(); }

This is similar to bug 34001 (which is already fixed), but for 'enum' instead
of 'if'. The problem is that 'BraceWrapping: { AfterEnum: true }' makes it
impossible to have one-line enums.

Since AllowShortBlocksOnASingleLine + AllowShortIfStatementsOnASingleLine allow
this for 'if', probably an AllowShortEnumsOnASingleLine should be added. That
way, one can independently control whether one-line enums are allowed and
whether multi-line enums should break before '{'.

-- 
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/20180501/a32bb3d7/attachment.html>


More information about the llvm-bugs mailing list