-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang-format] Misannotation of annotated function names #70603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-format Author: Björn Schäpers (HazardyKnusperkeks)
Taken from #69325:
`ANNOTATE() void foo();` will be annotated as:
```
AnnotatedTokens(L=0, P=0, T=5, C=0):
M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=identifier L=8 PPK=2 FakeLParens= FakeRParens=0 II=0x561bf7af7110 Text='ANNOTATE'
M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=9 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='('
M=0 C=0 T=FunctionAnnotationRParen S=0 F=0 B=0 BK=0 P=140 Name=r_paren L=10 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=')'
M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=void L=15 PPK=2 FakeLParens= FakeRParens=0 II=0x561bf7abb610 Text='void'
M=0 C=0 T=TrailingAnnotation S=1 F=0 B=0 BK=0 P=23 Name=identifier L=19 PPK=2 FakeLParens= FakeRParens=0 II=0x561bf7af7140 Text='foo'
M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=20 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='('
M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=140 Name=r_paren L=21 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=semi L=22 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';'
```
Obviously it shouldn't be `TrailingAnnotation`, but `FunctionDeclarationName`, if `ANNOTATE` is declared as `AttributeMacros` the annotation is:
```
AnnotatedTokens(L=0, P=0, T=5, C=0):
M=0 C=0 T=AttributeMacro S=1 F=0 B=0 BK=0 P=0 Name=identifier L=8 PPK=2 FakeLParens= FakeRParens=0 II=0x564eba5a7f40 Text='ANNOTATE'
M=0 C=0 T=AttributeLParen S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=9 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='('
M=0 C=0 T=AttributeRParen S=0 F=0 B=0 BK=0 P=140 Name=r_paren L=10 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=')'
M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=void L=15 PPK=2 FakeLParens= FakeRParens=0 II=0x564eba56bd80 Text='void'
M=0 C=1 T=FunctionDeclarationName S=1 F=0 B=0 BK=0 P=80 Name=identifier L=19 PPK=2 FakeLParens= FakeRParens=0 II=0x564eba5a8138 Text='foo'
M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=l_paren L=20 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='('
M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=140 Name=r_paren L=21 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=semi L=22 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';'
```
Which gets that one right.
There are multiple questions here for me:
@mydeveloperday @owenca @rymiel |
Did you mean function annotation? The first case has a FunctionAnnotationRParen, I assume that's what you're referring to. |
And the attributes have
The examples for the function annotations in out tests and in #69325 the macros which get Are there any function annotations, which are not attributes in reality? Should |
I think function annotations are one type of attributes.
I would wait.
We should leave it alone for now and let the user use |
Then we are done here. :) |
Taken from #69325:
ANNOTATE() void foo();
will be annotated as:Obviously it shouldn't be
TrailingAnnotation
, butFunctionDeclarationName
, ifANNOTATE
is declared asAttributeMacros
the annotation is:Which gets that one right.
There are multiple questions here for me:
AttributeRParen
and the return type? The code from [clang-format] Incorrect formatting for annotated constrained functions #69325 is not nicely formatted with theAttributeMacros
set.@mydeveloperday @owenca @rymiel
The text was updated successfully, but these errors were encountered: