Skip to content

[Formatter/ObjC] @selector(method:arg:) tends to be line-wrapped around the ( rather than : #36459

@llvmbot

Description

@llvmbot
Bugzilla Link 37111
Version unspecified
OS MacOS X
Attachments [example inputhttps://user-images.githubusercontent.com/60944935/143757376-51cc87f2-2846-42ca-b636-df04ebe87af9.gz)
Reporter LLVM Bugzilla Contributor

Extended Description

clang-format binds method argument : tighter than @​selector(, resulting in the following odd formatting.

See also: https://bugs.chromium.org/p/chromium/issues/detail?id=711737

input.m:

- (void)test {
    if ([object respondsToSelector:@selector(selectorNameThatIsReallyLong:param1:param2:)])
        return;
}

$ clang-format -style=llvm input.m

- (void)test {
  if ([object respondsToSelector:@selector
              (selectorNameThatIsReallyLong:param1:param2:)])
    return;
}
$ clang-format --version
clang-format version 7.0.0 (tags/google/stable/2018-01-11)

The @selector and its ( should remain together

I have not been able to find a combination of config options that avoids this behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions