Page MenuHomePhabricator

[clang-format] Don't insert space between ObjC class and lightweight generic
ClosedPublic

Authored by benhamilton on Apr 10 2018, 12:57 PM.

Details

Summary

In D45185, I added clang-format parser support for Objective-C
generics. However, I didn't touch the whitespace logic, so they
got the same space logic as Objective-C protocol lists.

In every example in the Apple SDK and in the documentation,
there is no space between the class name and the opening <
for the lightweight generic specification, so this diff
removes the space and updates the tests.

Test Plan: Tests updated. Ran tests with:

% make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Diff Detail

Repository
rL LLVM

Event Timeline

benhamilton created this revision.Apr 10 2018, 12:57 PM
djasper accepted this revision.Apr 12 2018, 5:30 AM

Looks good.

lib/Format/TokenAnnotator.cpp
2357 ↗(On Diff #141891)

Don't use else after return.
https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

I'd have a slight preference for writing:

bool IsLightweightGeneric = 
    Right.MatchingParen && Right.MatchingParen->Next &&
    Right.MatchingParen->Next->is(tok::colon);
return !IsLightweightGeneric && Style.ObjCSpaceBeforeProtocolList;

Then I think it might not even need a comment (or a shorter one).

This revision is now accepted and ready to land.Apr 12 2018, 5:30 AM
benhamilton marked an inline comment as done.

Avoid else after return. Clean up logic so it doesn't need a comment.

This revision was automatically updated to reflect the committed changes.