[llvm-bugs] [Bug 52015] New: [Formatter/Objective-C] Formatter should put __attribute__((foo)) on its own line before @interface / @implementation / @protocol

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 29 12:10:59 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52015

            Bug ID: 52015
           Summary: [Formatter/Objective-C] Formatter should put
                    __attribute__((foo)) on its own line before @interface
                    / @implementation / @protocol
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bhamiltoncx at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

`ClangFormat` incorrectly removes line breaks after `__attribute__((foo))` when
followed by Objective-C `@interface` / `@implementation` / `@protocol`:

% cat /tmp/test.h
__attribute__((objc_subclassing_restricted))
@interface Foo
@end

% ./clang-format -debug -style=Google /tmp/test.h
Args: ./clang-format -debug -style=Google /tmp/test.h 
File encoding: UTF8
Language: C++
----
Line(0, FSC=0): __attribute[T=88, OC=0] l_paren[T=88, OC=13] l_paren[T=88,
OC=14] identifier[T=88, OC=15] r_paren[T=88, OC=42] r_paren[T=88, OC=43]
at[T=88, OC=0] identifier[T=88, OC=1] identifier[T=88, OC=11] 
Line(0, FSC=0): at[T=88, OC=0] identifier[T=88, OC=1] 
Line(0, FSC=0): eof[T=88, OC=0] 
Run 0...
Detected ObjC at location /tmp/test.h:2:1 token: @ token type: ObjCDecl
Replacements for run 0:
File encoding: UTF8
Language: Objective-C
----
Line(0, FSC=0): __attribute[T=88, OC=0] l_paren[T=88, OC=13] l_paren[T=88,
OC=14] identifier[T=88, OC=15] r_paren[T=88, OC=42] r_paren[T=88, OC=43]
at[T=88, OC=0] identifier[T=88, OC=1] identifier[T=88, OC=11] 
Line(0, FSC=0): at[T=88, OC=0] identifier[T=88, OC=1] 
Line(0, FSC=0): eof[T=88, OC=0] 
Run 0...
AnnotatedTokens(L=0):
 M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=__attribute L=13 PPK=2
FakeLParens= FakeRParens=0 II=0x55c3be1fb758 Text='__attribute__'
 M=0 C=0 T=AttributeParen S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=14 PPK=2
FakeLParens= FakeRParens=0 II=0x0 Text='('
 M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=l_paren L=15 PPK=2 FakeLParens=
FakeRParens=0 II=0x0 Text='('
 M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=79 Name=identifier L=42 PPK=2
FakeLParens= FakeRParens=0 II=0x55c3be230810 Text='objc_subclassing_restricted'
 M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=63 Name=r_paren L=43 PPK=2 FakeLParens=
FakeRParens=0 II=0x0 Text=')'
 M=0 C=0 T=AttributeParen S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=44 PPK=2
FakeLParens= FakeRParens=0 II=0x0 Text=')'
 M=0 C=1 T=ObjCDecl S=1 F=0 B=0 BK=0 P=23 Name=at L=46 PPK=2 FakeLParens=
FakeRParens=0 II=0x0 Text='@'
 M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=identifier L=55 PPK=2
FakeLParens= FakeRParens=0 II=0x55c3be22f498 Text='interface'
 M=0 C=0 T=StartOfName S=1 F=0 B=0 BK=0 P=220 Name=identifier L=59 PPK=2
FakeLParens= FakeRParens=0 II=0x55c3be230840 Text='Foo'
----
AnnotatedTokens(L=0):
 M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=at L=1 PPK=2 FakeLParens=
FakeRParens=0 II=0x0 Text='@'
 M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=identifier L=4 PPK=2 FakeLParens=
FakeRParens=0 II=0x55c3be22f428 Text='end'
----
AnnotatedTokens(L=0):
 M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens=
FakeRParens=0 II=0x0 Text=''
----
Replacements for run 0:
/tmp/test.h: 44:+1:" "
__attribute__((objc_subclassing_restricted)) @interface Foo
@end

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210929/56dbc6ed/attachment.html>


More information about the llvm-bugs mailing list