From: Daniel Jasper Date: Thu, 19 May 2016 06:19:17 +0000 (+0000) Subject: clang-format: Fix enumerator case ranges. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a2da625d3ab9ab294efb2ac19a5c577e8618fb5;p=clang clang-format: Fix enumerator case ranges. Before: case a... b: break; After: case a ... b: break; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270027 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 2191864da2..bdf3dc3e57 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 1b434eb8c9..aec801ccc9 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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" "}"); }