clang-format: Fix enumerator case ranges.

Before:
  case a... b: break;

After:
  case a ... b: break;

llvm-svn: 270027
This commit is contained in:
Daniel Jasper 2016-05-19 06:19:17 +00:00
parent 19e04b6430
commit e2fab13313
2 changed files with 3 additions and 1 deletions

View File

@ -1965,7 +1965,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less))
return false;
if (Right.is(tok::ellipsis))
return Left.Tok.isLiteral();
return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous &&
Left.Previous->is(tok::kw_case));
if (Left.is(tok::l_square) && Right.is(tok::amp))
return false;
if (Right.is(TT_PointerOrReference))

View File

@ -755,6 +755,7 @@ TEST_F(FormatTest, CaseRanges) {
verifyFormat("switch (x) {\n"
"case 'A' ... 'Z':\n"
"case 1 ... 5:\n"
"case a ... b:\n"
" break;\n"
"}");
}