[llvm-bugs] [Bug 43734] New: Clang-format: BraceWrapping/AfterCaseLabel default value does not match old behavior

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 20 09:39:58 PDT 2019


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

            Bug ID: 43734
           Summary: Clang-format: BraceWrapping/AfterCaseLabel default
                    value does not match old behavior
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jordan.woyak at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

With the addition of the BraceWrapping/AfterCaseLabel option the default
behavior has changed and it seems impossible to produce a .clang-format file
which produces consistent output across versions.

The following .clang-format file produces different output depending on the
clang-format version.

---
BreakBeforeBraces: Custom
BraceWrapping:
  AfterControlStatement: true
  AfterFunction:   true

$ clang-format --version
clang-format version 7.0.0 (tags/RELEASE_700/final)

$ clang-format <<< 'switch (42) { default:{ break; } }'
switch (42)
{
default:
{
  break;
}
}

$ clang-format --version
clang-format version 9.0.0 (tags/RELEASE_900/final)

$ clang-format <<< 'switch (42) { default:{ break; } }'
switch (42) {
default: {
  break;
}
}

Note that adding `  AfterCaseLabel: true` restores the old behavior however
having this line stops older versions of clang-format from running.
`YAML:4:19: error: unknown key 'AfterCaseLabel'`

-- 
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/20191020/99b4ccdb/attachment.html>


More information about the llvm-bugs mailing list