Closed cb252c30-9e88-4eb4-891d-0e28e2d53015 closed 4 years ago
Revision submitted https://reviews.llvm.org/D68242
Note: clang-format needs people to do code reviews, please consider reviewing others work as its the only way we can get fixes into the trunk.
From the debug output, the TokenAnnotator was marking the first -> as being a Trailing return arrow because of the presence of the auto.
AnnotatedTokens(L=1): M=0 C=0 T=Unknown S=1 B=0 BK=0 P=0 Name=auto L=4 PPK=2 FakeLParens=0/ FakeRParens=0 II=0x174ae7de0a8 Text='auto' M=0 C=1 T=Unknown S=1 B=0 BK=0 P=80 Name=operator L=13 PPK=2 FakeLParens= FakeRParens=0 II=0x174ae7dec58 Text='operator' M=0 C=0 T=TrailingReturnArrow S=0 B=0 BK=0 P=23 Name=arrow L=15 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='->' ^^^^^^^^^^^^^^^^^^^^^^ M=0 C=0 T=OverloadedOperatorLParen S=1 B=0 BK=0 P=23 Name=l_paren L=17 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='(' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=140 Name=r_paren L=18 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=')' M=0 C=1 T=TrailingReturnArrow S=1 B=0 BK=0 P=23 Name=arrow L=21 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='->' M=0 C=0 T=Unknown S=1 B=0 BK=0 P=23 Name=int L=25 PPK=2 FakeLParens= FakeRParens=0 II=0x174ae7de3e0 Text='int' M=0 C=1 T=PointerOrReference S=1 B=0 BK=0 P=210 Name=star L=27 PPK=2 FakeLParens= FakeRParens=1 II=0x0 Text='*' M=0 C=0 T=Unknown S=0 B=0 BK=0 P=34 Name=semi L=28 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';'
I believe this is fairly easy to fix, let me prepare the revision and unit tests and send for review.
--- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1387,7 +1387,9 @@ private: Style.Language == FormatStyle::LK_Java) { Current.Type = TT_LambdaArrow; } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Extended Description
clang-format formats like:
class Bug { auto operator-> () -> int*; auto operator++(int) -> int; };
You can notice that a space inserted after 'operator->' while no space is inserted after 'operator++'.