This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Add support for generic Obj-C categories
AcceptedPublic

Authored by danielmartin on Aug 27 2017, 5:18 AM.

Details

Summary

Objective C supports lightweight generics in categories. This patch
adds support for that in clang-format.

Event Timeline

danielmartin created this revision.Aug 27 2017, 5:18 AM
djasper accepted this revision.Aug 27 2017, 11:14 PM

Looks good.

lib/Format/UnwrappedLineParser.cpp
2099

nit: Seems like this comment would fit on one line.

This revision is now accepted and ready to land.Aug 27 2017, 11:14 PM

Make comment fit in one line

fhahn added a subscriber: fhahn.Aug 29 2017, 3:52 AM

@rjmccall @Eugene.Zelenko this looks like it might still be relevant.

Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptSep 21 2023, 9:16 AM

Is that really the way we want to recommend formatting that, with the generics clause separated from the class name but not separated from the category clause? I'd expect the opposite: write the generics clause with no separation after the class name but with separation from the category clause, e.g. NSHashTable<ObjectType> (MYFoundation).

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please try to ensure all code changes have a unit test (unless this is an NFC or refactoring, adding documentation etc..)

Add your unit tests in clang/unittests/Format and you can build with ninja FormatTests. We recommend using the verifyFormat(xxx) format of unit tests rather than EXPECT_EQ as this will ensure you change is tolerant to random whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can happen if you are trying to improve the annotation phase to ensure we are correctly identifying the type of a token, please add a token annotator test in TokenAnnotatorTest.cpp