diff options
-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" |