diff options
| author | Daniel Jasper <djasper@google.com> | 2013-10-20 16:56:16 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-10-20 16:56:16 +0000 |
| commit | 2d0cd4978737bdde886d70cb82d5ce8fb385bfa2 (patch) | |
| tree | caf5392d9a6f5e55a776af140211503c7f76868e /clang | |
| parent | d489dd342bfdc2481a62633c8f8d66d6e2339dcb (diff) | |
| download | bcm5719-llvm-2d0cd4978737bdde886d70cb82d5ce8fb385bfa2.tar.gz bcm5719-llvm-2d0cd4978737bdde886d70cb82d5ce8fb385bfa2.zip | |
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
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9bc109787ae..7e794a3d2d5 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index dcb708e0d78..ad1cf75392b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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" |

