Fix indentation for case: // comment.

Before:
switch (x) {
case 1:
    // Do amazing stuff
    {
  g();
  f();
}
}

After:
switch (x) {
case 1:
  // Do amazing stuff
  {
    g();
    f();
  }
}

llvm-svn: 177420
This commit is contained in:
Daniel Jasper 2013-03-19 18:33:58 +00:00
parent 6a38438e55
commit 2bd32ca92a
2 changed files with 10 additions and 1 deletions

View File

@ -576,7 +576,7 @@ void UnwrappedLineParser::parseLabel() {
unsigned OldLineLevel = Line->Level;
if (Line->Level > 0)
--Line->Level;
if (FormatTok.Tok.is(tok::l_brace)) {
if (CommentsBeforeNextToken.empty() && FormatTok.Tok.is(tok::l_brace)) {
parseBlock(/*MustBeDeclaration=*/ false);
if (FormatTok.Tok.is(tok::kw_break))
parseStructuralElement(); // "break;" after "}" goes on the same line.

View File

@ -432,6 +432,15 @@ TEST_F(FormatTest, FormatsSwitchStatement) {
"case 1:\n"
" f();\n"
"}");
verifyFormat("switch (x) {\n"
"case 1:\n"
" // Do amazing stuff\n"
" {\n"
" f();\n"
" g();\n"
" }\n"
" break;\n"
"}");
verifyGoogleFormat("switch (x) {\n"
" case 1:\n"