clang-format: Support case ranges.

Before (note the missing space before "..." which can lead to compile
errors):
  switch (x) {
    case 'A'... 'Z':
    case 1... 5:
        break;
  }

After:
  switch (x) {
    case 'A' ... 'Z':
    case 1 ... 5:
        break;
  }

llvm-svn: 193050
This commit is contained in:
Daniel Jasper 2013-10-20 16:56:16 +00:00
parent d489dd342b
commit 2d0cd49787
2 changed files with 9 additions and 1 deletions

View File

@ -1237,7 +1237,7 @@ 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 false;
return Left.Tok.isLiteral();
if (Left.is(tok::l_square) && Right.is(tok::amp))
return false;
if (Right.Type == TT_PointerOrReference)

View File

@ -590,6 +590,14 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
"});");
}
TEST_F(FormatTest, CaseRanges) {
verifyFormat("switch (x) {\n"
"case 'A' ... 'Z':\n"
"case 1 ... 5:\n"
" break;\n"
"}");
}
TEST_F(FormatTest, FormatsLabels) {
verifyFormat("void f() {\n"
" some_code();\n"