From 181046566cbcc0a2e0f43cbb08ab4896b7a2a901 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 12 Mar 2013 12:26:55 +0000 Subject: [PATCH] Remove bad space after "default". Before: switch (x) { default : {} } After: switch (x) { default: {} } llvm-svn: 176861 --- clang/lib/Format/TokenAnnotator.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f642a7030917..77815b0406b5 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1042,7 +1042,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Tok.Type == TT_OverloadedOperatorLParen) return false; if (Tok.is(tok::colon)) - return Line.First.isNot(tok::kw_case) && !Tok.Children.empty() && + return Line.First.isNot(tok::kw_case) && + Line.First.isNot(tok::kw_default) && !Tok.Children.empty() && Tok.Type != TT_ObjCMethodExpr; if (Tok.is(tok::l_paren) && !Tok.Children.empty() && Tok.Children[0].Type == TT_PointerOrReference && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0ac3c10dc741..caf291fc9d71 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -423,6 +423,10 @@ TEST_F(FormatTest, FormatsSwitchStatement) { "}"); verifyFormat("switch (test)\n" " ;"); + verifyFormat("switch (x) {\n" + "default: {\n" + " // Do nothing.\n" + "}"); verifyGoogleFormat("switch (x) {\n" " case 1:\n"