[llvm-bugs] [Bug 40489] New: clang-format with BreakBeforeBraces: Allman removes brace break at selector beginning

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jan 27 13:37:12 PST 2019


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

            Bug ID: 40489
           Summary: clang-format with BreakBeforeBraces: Allman removes
                    brace break at selector beginning
           Product: clang
           Version: 7.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sophia at smartelectronix.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 21391
  --> https://bugs.llvm.org/attachment.cgi?id=21391&action=edit
example source code + clang-format configuration file

The following code:

@interface Stuff
@end

@implementation Stuff

- (void)method
{
  int a = 0;
  if (YES)
  {
    a++;
  }
}

@end

if run through clang-form with configuration:
BreakBeforeBraces: Allman

then the method body changes to:
- (void)method {
  int a = 0;
  if (YES)
  {
    a++;
  }
}

which is incorrect brace breaking after the method signature.  Everything else,
like the if block, formats brace line breaks correctly.

I have attached the example source file and .clang-format and ran the following
with it:
clang-format -i test.m

This is a regression introduced in 7.0 (version 6.0.1 did not have this bug).

This is an upgrade blocker for me as it riddles Objective-C projects with new
diffs that are all incorrect.


I also tried adding the following language-specific section as an attempted
workaround:

---
Language: ObjC
BreakBeforeBraces: Custom
BraceWrapping:
  AfterClass: true
  AfterControlStatement: true
  AfterEnum: true
  AfterExternBlock: true
  AfterFunction: true
  AfterNamespace: true
  AfterObjCDeclaration: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: true
  BeforeElse: true
  IndentBraces: false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true

but it did not resolve the issue.

-- 
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/20190127/35c0fdfa/attachment.html>


More information about the llvm-bugs mailing list