macros in front of @interface / @protocol for ObjC code confuse clang-format |
||||||||
Issue descriptionclang-format produced code that no sane human would ever choose Here's the code before formatting: >FOUNDATION_EXPORT NS_AVAILABLE_IOS(10.0) >@interface Foo : NSObject >@property(assign, readwrite) NSInteger bar; >@end > >class Quux; Here's the code after formatting: >FOUNDATION_EXPORT NS_AVAILABL_IOS(10.0) @interface Foo > : NSObject @property(assign, readwrite) NSInteger bar; >@end > > class Quux; Here's how it ought to look: The input file is already pretty well-formatted. At the very least, - |@property| should start on its own line - |class Quux| should not be indented! The problem seems to be in the FOUNDATION_EXPORT + NS_AVAILABLE_IOS(10.0) directives: removing either one of them fixes the bug.
,
Dec 11 2017
,
Dec 11 2017
clang-format is owned by the clang team, which is not part of the chromium team: https://llvm.googlesource.com/clang/ clang-format has a chromium mode which is based off of chromium's style guide, and chromium simply uses that mode: https://chromium.googlesource.com/chromium/src/+/b4aadc32a7fd6d42ac3cc9adbb20a8ee4a267572/.clang-format Please work with them to either update the style guide, or update clang-format's implementation of the style guide.
,
Dec 12 2017
Thanks! In that case, should someone update https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_format.md, which seems to imply that this is the correct place to file bugs in how clang-format deals with chromium code?
,
Dec 12 2017
Ah, interesting. That bug template link seems to do (mostly) the right thing. The problem is that the bugs are then getting triaged to me, because nick@ and thakis@ aren't acting on them in the first few days of their existence. I'll reopen this, assign to nick, and remove the Codereview component. nick or thakis, please make sure that you triage these bugs in a timely manner. Probably a good idea to create a component for clang-format, and update that doc to add that component to the bug it creates.
,
Dec 15 2017
,
Jan 18 2018
> nick or thakis, please make sure that you triage these bugs in a timely manner. Looks like both nick and I are on paternity leave, as indicated by our crbug statuses. (I'm slowly returning though.)
,
Jan 23 2018
Did something in http://llvm.org/viewvc/llvm-project?rev=323226&view=rev, now outputs: $ echo 'FOUNDATION_EXPORT NS_AVAILABLE_IOS(10.0) @interface Foo : NSObject @property(assign, readwrite) NSInteger bar; @end' | bin/clang-format --assume-filename=foo.m FOUNDATION_EXPORT NS_AVAILABLE_IOS(10.0) @interface Foo : NSObject @property(assign, readwrite) NSInteger bar; @end which seems decent enough. Now only needs a clang-format roll to become active.
,
Oct 16
,
Nov 26
A clang-format with the fix got deployed on Nov 21 2018. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by brajkumar@chromium.org
, Dec 11 2017