<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-format with BreakBeforeBraces: Allman removes brace break at selector beginning"
   href="https://bugs.llvm.org/show_bug.cgi?id=40489">40489</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format with BreakBeforeBraces: Allman removes brace break at selector beginning
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sophia@smartelectronix.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21391" name="attach_21391" title="example source code + clang-format configuration file">attachment 21391</a> <a href="attachment.cgi?id=21391&action=edit" title="example source code + clang-format configuration file">[details]</a></span>
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>