This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Improve detection of ObjC for-in statements
AbandonedPublic

Authored by benhamilton on Feb 28 2018, 1:41 PM.

Details

Reviewers
krasimir
jolesiak
Summary

Previously, clang-format would detect the following as an
Objective-C for-in statement:

for (int x = in.value(); ...) {}

because the logic only decided a for-loop was definitely *not*
an Objective-C for-in loop after it saw a semicolon or a colon.

To fix this, I delayed the decision of whether this was a for-in
statement until after we found the matching right-paren, at which
point we know if we've seen a semicolon or not.

Depends On D43904

Test Plan: New tests added. Ran tests with:

make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Diff Detail

Event Timeline

benhamilton created this revision.Feb 28 2018, 1:41 PM
benhamilton abandoned this revision.Feb 28 2018, 1:44 PM

Whoops, sent out twice.