r270027 - clang-format: Fix enumerator case ranges.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 23:19:18 PDT 2016
Author: djasper
Date: Thu May 19 01:19:17 2016
New Revision: 270027
URL: http://llvm.org/viewvc/llvm-project?rev=270027&view=rev
Log:
clang-format: Fix enumerator case ranges.
Before:
case a... b: break;
After:
case a ... b: break;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=270027&r1=270026&r2=270027&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu May 19 01:19:17 2016
@@ -1965,7 +1965,8 @@ bool TokenAnnotator::spaceRequiredBetwee
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))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=270027&r1=270026&r2=270027&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 19 01:19:17 2016
@@ -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"
"}");
}
More information about the cfe-commits
mailing list