gedare updated this revision to Diff 558069. gedare added a comment. Use cameLCAse in test
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154755/new/ https://reviews.llvm.org/D154755 Files: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25789,8 +25789,8 @@ "}", Style); - verifyFormat("if (quitelongarg !=\n" - " (alsolongarg - 1)) { // ABC is a very longgggggggggggg " + verifyFormat("if (quiteLongArg !=\n" + " (alsoLongArg - 1)) { // ABC is a very longgggggggggggg " "comment\n" " return;\n" "}", @@ -25803,12 +25803,44 @@ "}", Style); - verifyFormat("if (quitelongarg !=\n" - " (alsolongarg - 1)) { // ABC is a very longgggggggggggg " + verifyFormat("if (quiteLongArg !=\n" + " (alsoLongArg - 1)) { // ABC is a very longgggggggggggg " "comment\n" " return;\n" "}", Style); + + verifyFormat("void foo() {\n" + " if (camelCaseName < alsoLongName ||\n" + " anotherEvenLongerName <=\n" + " thisReallyReallyReallyReallyReallyReallyLongerName ||" + "\n" + " otherName < thisLastName) {\n" + " return;\n" + " } else if (quiteLongName < alsoLongName ||\n" + " anotherEvenLongerName <=\n" + " thisReallyReallyReallyReallyReallyReallyLonger" + "Name ||\n" + " otherName < thisLastName) {\n" + " return;\n" + " }\n" + "}", + Style); + + Style.ContinuationIndentWidth = 2; + verifyFormat("void foo() {\n" + " if (ThisIsRatherALongIfClause && thatIExpectToBeBroken ||\n" + " ontoMultipleLines && whenFormattedCorrectly) {\n" + " if (false) {\n" + " return;\n" + " } else if (thisIsRatherALongIfClause && " + "thatIExpectToBeBroken ||\n" + " ontoMultipleLines && whenFormattedCorrectly) {\n" + " return;\n" + " }\n" + " }\n" + "}", + Style); } TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentForStatement) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -777,8 +777,10 @@ Style.Cpp11BracedListStyle)) && State.Column > getNewLineColumn(State) && (!Previous.Previous || - !Previous.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, - tok::kw_switch)) && + !(Previous.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, + tok::kw_switch) || + (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent && + Previous.Previous->isIf()))) && // Don't do this for simple (no expressions) one-argument function calls // as that feels like needlessly wasting whitespace, e.g.: //
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25789,8 +25789,8 @@ "}", Style); - verifyFormat("if (quitelongarg !=\n" - " (alsolongarg - 1)) { // ABC is a very longgggggggggggg " + verifyFormat("if (quiteLongArg !=\n" + " (alsoLongArg - 1)) { // ABC is a very longgggggggggggg " "comment\n" " return;\n" "}", @@ -25803,12 +25803,44 @@ "}", Style); - verifyFormat("if (quitelongarg !=\n" - " (alsolongarg - 1)) { // ABC is a very longgggggggggggg " + verifyFormat("if (quiteLongArg !=\n" + " (alsoLongArg - 1)) { // ABC is a very longgggggggggggg " "comment\n" " return;\n" "}", Style); + + verifyFormat("void foo() {\n" + " if (camelCaseName < alsoLongName ||\n" + " anotherEvenLongerName <=\n" + " thisReallyReallyReallyReallyReallyReallyLongerName ||" + "\n" + " otherName < thisLastName) {\n" + " return;\n" + " } else if (quiteLongName < alsoLongName ||\n" + " anotherEvenLongerName <=\n" + " thisReallyReallyReallyReallyReallyReallyLonger" + "Name ||\n" + " otherName < thisLastName) {\n" + " return;\n" + " }\n" + "}", + Style); + + Style.ContinuationIndentWidth = 2; + verifyFormat("void foo() {\n" + " if (ThisIsRatherALongIfClause && thatIExpectToBeBroken ||\n" + " ontoMultipleLines && whenFormattedCorrectly) {\n" + " if (false) {\n" + " return;\n" + " } else if (thisIsRatherALongIfClause && " + "thatIExpectToBeBroken ||\n" + " ontoMultipleLines && whenFormattedCorrectly) {\n" + " return;\n" + " }\n" + " }\n" + "}", + Style); } TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentForStatement) { Index: clang/lib/Format/ContinuationIndenter.cpp =================================================================== --- clang/lib/Format/ContinuationIndenter.cpp +++ clang/lib/Format/ContinuationIndenter.cpp @@ -777,8 +777,10 @@ Style.Cpp11BracedListStyle)) && State.Column > getNewLineColumn(State) && (!Previous.Previous || - !Previous.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, - tok::kw_switch)) && + !(Previous.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, + tok::kw_switch) || + (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent && + Previous.Previous->isIf()))) && // Don't do this for simple (no expressions) one-argument function calls // as that feels like needlessly wasting whitespace, e.g.: //
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits