]> granicus.if.org Git - clang/commit
[clang-format] Do not insert space before closing brace in ObjC dict literal
authorBen Hamilton <benhamilton@google.com>
Tue, 27 Mar 2018 15:01:17 +0000 (15:01 +0000)
committerBen Hamilton <benhamilton@google.com>
Tue, 27 Mar 2018 15:01:17 +0000 (15:01 +0000)
commitd62e1f96238fe3a454ae437b2fd923cdec62525a
tree786c81eaa776cee67e282c9cac7f36f774cf43dd
parent1f49997a41184b77893950b460573ee7731b0cbc
[clang-format] Do not insert space before closing brace in ObjC dict literal

Summary:
Previously, `clang-format` would sometimes insert a space
before the closing brace in an Objective-C dictionary literal.

Unlike array literals (which obey `Style.SpacesInContainerLiterals`
to add a space after `[` and before `]`), Objective-C dictionary
literals currently are not meant to insert a space after `{` and before
`}`, regardless of `Style.SpacesInContainerLiterals`.

However, some constructs like `@{foo : @(bar)}` caused `clang-format`
to insert a space between `)` and `}`.

This fixes the issue and adds tests. (I understand the behavior is
not consistent between array literals and dictionary literals, but
that's existing behavior that's a much larger change.)

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak, Wizard

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D44816

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328627 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestObjC.cpp