This is an archive of the discontinued LLVM Phabricator instance.

[Format/ObjC] Fix [foo bar]->baz formatting as lambda arrow
ClosedPublic

Authored by benhamilton on Feb 7 2019, 1:23 PM.

Details

Summary

Currently, UnwrappedLineParser thinks an arrow token after
an ObjC method expression is a C++ lambda arrow, so it formats:

[foo bar]->baz

as:

[foo bar] -> baz

Because UnwrappedLineParser runs before TokenAnnotator, it can't
know if the arrow token is after an ObjC method expression or not.

This diff makes TokenAnnotator remove the TT_LambdaArrow on
the arrow token if it follows an ObjC method expression.

Test Plan: New test added. Ran test with:

% ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
Confirmed test failed before diff and passed after diff.

Diff Detail

Repository
rC Clang

Event Timeline

benhamilton created this revision.Feb 7 2019, 1:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 1:23 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Tidy up code.

sammccall accepted this revision.Feb 8 2019, 7:22 AM
This revision is now accepted and ready to land.Feb 8 2019, 7:22 AM
This revision was automatically updated to reflect the committed changes.