[PATCH] Update block formatting to behave like Xcode

Brian King brianaking at gmail.com
Tue May 5 13:39:41 PDT 2015


Here's an update that does two things

1. Splits the behavior changes into 2 bools, since they were controlling distinct formatting behaviors
2. Adds support for non-zero column width for ObjCAvoidLineBreaksForInlineBlocks. Currently there's potentially broken behavior, where the decision to split an objective-c line is determined by the length of the opening `[` to the close `]`. In the case of in-line blocks, that calculation is deceptive as it includes blocks, which break the line. I added getLengthToLineTerminator that matches the closing `]` or the first token with children lines. I only changed this behavior when ObjCAvoidLineBreaksForInlineBlocks is enabled, but it could be argued that this should be default behavior. I opted for compatibility unless you think otherwise.


http://reviews.llvm.org/D9237

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9237.24971.patch
Type: text/x-patch
Size: 8628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150505/ce0dab26/attachment.bin>


More information about the cfe-commits mailing list