]> granicus.if.org Git - clang/commitdiff
Remove bad space after "default".
authorDaniel Jasper <djasper@google.com>
Tue, 12 Mar 2013 12:26:55 +0000 (12:26 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 12 Mar 2013 12:26:55 +0000 (12:26 +0000)
Before:
switch (x) {
default : {}
}

After:
switch (x) {
default: {}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176861 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index f642a7030917f5cfd9b31b7874f5faae069c7e16..77815b0406b5fbfa5ffa392e0830629664208ef3 100644 (file)
@@ -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 &&
index 0ac3c10dc74154095ae6084565fca50a77c6f8bd..caf291fc9d71fbcd482dd60e31bfd992289a6d1b 100644 (file)
@@ -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"