[clang-format] Don't insert space between r_paren and 'new' in ObjC decl
authorBen Hamilton <benhamilton@google.com>
Thu, 22 Mar 2018 03:23:53 +0000 (03:23 +0000)
committerBen Hamilton <benhamilton@google.com>
Thu, 22 Mar 2018 03:23:53 +0000 (03:23 +0000)
commit5f91134344114826644b920d6fd5ec5b88ca47cb
tree390b115857499e95de5bbbf020b4d783fe97cbb6
parent97608445b12e93b95111031492d8a46a97f33db3
[clang-format] Don't insert space between r_paren and 'new' in ObjC decl

Summary:
Previously, clang-format would insert a space between
the closing parenthesis and 'new' in the following valid Objective-C
declaration:

  + (instancetype)new;

This was because 'new' is treated as a keyword, not an identifier.

TokenAnnotator::spaceRequiredBefore() already handled the case where
r_paren came before an identifier, so this diff extends it to
handle r_paren before 'new'.

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

Reviewers: djasper, jolesiak, stephanemoore

Reviewed By: djasper, jolesiak, stephanemoore

Subscribers: stephanemoore, klimek, cfe-commits

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

llvm-svn: 328174
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestObjC.cpp