[llvm-bugs] [Bug 36976] New: [Formatter/ObjC] Formatter should not parse return type of ObjC method as cast
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 2 09:36:43 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=36976
Bug ID: 36976
Summary: [Formatter/ObjC] Formatter should not parse return
type of ObjC method as cast
Product: clang
Version: trunk
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
This bug is from the discussion at https://reviews.llvm.org/D44996 .
Currently, clang-format parses the r_paren in an ObjC method return type as
TT_CastRParen:
===
% echo "-(void)foo;" | ./bin/clang-format -debug -
Language: Objective-C
----
Line(0, FSC=0): minus[T=68, OC=0] l_paren[T=68, OC=1] void[T=68, OC=2]
r_paren[T=68, OC=6] identifier[T=68, OC=7] semi[T=68, OC=10]
Line(0, FSC=0): eof[T=68, OC=0]
Run 0...
AnnotatedTokens(L=0):
M=0 C=0 T=ObjCMethodSpecifier S=1 B=0 BK=0 P=0 Name=minus L=1 PPK=2
FakeLParens= FakeRParens=0 Text='-'
M=0 C=1 T=Unknown S=1 B=0 BK=0 P=33 Name=l_paren L=3 PPK=2
FakeLParens= FakeRParens=0 Text='('
M=0 C=1 T=Unknown S=0 B=0 BK=0 P=140 Name=void L=7 PPK=2 FakeLParens=
FakeRParens=0 Text='void'
M=0 C=0 T=CastRParen S=0 B=0 BK=0 P=43 Name=r_paren L=8 PPK=2
FakeLParens= FakeRParens=0 Text=')'
M=0 C=1 T=TrailingAnnotation S=0 B=0 BK=0 P=120 Name=identifier L=11
PPK=2 FakeLParens= FakeRParens=0 Text='foo'
M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=12 PPK=2 FakeLParens=
FakeRParens=0 Text=';'
===
This seems unintentional; @djasper and I agreed we should revisit this.
There is at least one place which relies on TT_CastRParen being an indicator of
an ObjC method return type:
https://github.com/llvm-mirror/clang/blob/e37a191e99773959118155304ec2ed0bc0d591c2/lib/Format/TokenAnnotator.cpp#L394
so we will need to fix this carefully.
--
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/20180402/ba373189/attachment.html>
More information about the llvm-bugs
mailing list