forked from OSchip/llvm-project
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:
parent
d489dd342b
commit
2d0cd49787
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue