diff options
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 2 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index a438a53c37..b43cc076b2 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -574,7 +574,7 @@ void UnwrappedLineParser::parseLabel() { return; nextToken(); unsigned OldLineLevel = Line->Level; - if (Line->Level > 0) + if (Line->Level > 1 || (!Line->InPPDirective && Line->Level > 0)) --Line->Level; if (CommentsBeforeNextToken.empty() && FormatTok.Tok.is(tok::l_brace)) { parseBlock(/*MustBeDeclaration=*/ false); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 18ba143e00..3253347686 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -441,6 +441,11 @@ TEST_F(FormatTest, FormatsSwitchStatement) { " }\n" " break;\n" "}"); + verifyFormat("#define A \\\n" + " switch (x) { \\\n" + " case a: \\\n" + " foo = b; \\\n" + " }", getLLVMStyleWithColumns(20)); verifyGoogleFormat("switch (x) {\n" " case 1:\n" @@ -1209,7 +1214,7 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) { // FIXME: Improve formatting of case labels in macros. verifyFormat("#define SOMECASES \\\n" - "case 1: \\\n" + " case 1: \\\n" " case 2\n", getLLVMStyleWithColumns(20)); |