[all-commits] [llvm/llvm-project] 2a0590: [clang-format] Keep the ObjC selector name and `@s...

sstwcw via All-commits all-commits at lists.llvm.org
Fri Oct 3 13:41:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2a059042882ed5108478c635322e4e94439386f5
      https://github.com/llvm/llvm-project/commit/2a059042882ed5108478c635322e4e94439386f5
  Author: sstwcw <su3e8a96kzlver at posteo.net>
  Date:   2025-10-03 (Fri, 03 Oct 2025)

  Changed paths:
    M clang/lib/Format/Format.cpp
    M clang/lib/Format/FormatToken.h
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTestObjC.cpp
    M clang/unittests/Format/TokenAnnotatorTest.cpp

  Log Message:
  -----------
  [clang-format] Keep the ObjC selector name and `@selector` together (#160739)

Fixes #36459.

after

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

before

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

Before this patch, the `ObjCMethodExpr` type was assigned to many kinds
of tokens. The rule for allowing breaking the line before the colon on
line TokenAnnotator.cpp:6289 was intended for method declarations and
calls. It matched the parenthesis following `@selector` by mistake. To
fix the problem, this patch adds a new type for `@selector`. Most of the
special things in the code related to the old type is intended for other
constructs. So most of the code related to the old type is not changed
in this patch.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list