New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 793316 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 26
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 2
Type: Bug

Blocked on:
issue 768586



Sign in to add a comment

macros in front of @interface / @protocol for ObjC code confuse clang-format

Project Member Reported by lilyhoughton@google.com, Dec 8 2017

Issue description

clang-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.
 
test.mm
119 bytes Download
Labels: Needs-Milestone OS-iOS

Comment 2 by pkl@chromium.org, Dec 11 2017

Components: Infra>Codereview
Labels: Pri-2

Comment 3 by aga...@chromium.org, Dec 11 2017

Components: -Infra>Codereview Infra>Codereview>Gerrit
Status: WontFix (was: Unconfirmed)
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.


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?

Comment 5 by aga...@chromium.org, Dec 12 2017

Components: -Infra>Codereview>Gerrit
Owner: nick@chromium.org
Status: Assigned (was: WontFix)
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.
Components: Tools Build

Comment 7 by thakis@chromium.org, 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.)

Comment 8 by thakis@chromium.org, Jan 23 2018

Blockedon: 768586
Owner: thakis@chromium.org
Status: Started (was: Assigned)
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.
Summary: macros in front of @interface / @protocol for ObjC code confuse clang-format (was: clang-format quality problem)
Labels: allpublic
Status: Fixed (was: Started)
A clang-format with the fix got deployed on Nov 21 2018.

Sign in to add a comment