forked from OSchip/llvm-project
[clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine
https://bugs.llvm.org/show_bug.cgi?id=47936 Using the MultiLine setting for BraceWrapping.AfterControlStatement appears to disable AllowShortFunctionsOnASingleLine, even in cases without any control statements Reviewed By: HazardyKnusperkeks, curdeius Differential Revision: https://reviews.llvm.org/D114521
This commit is contained in:
parent
8804d08e99
commit
72e4f4a2a1
|
@ -676,7 +676,7 @@ private:
|
|||
// { <-- current Line
|
||||
// baz();
|
||||
// }
|
||||
if (Line.First == Line.Last &&
|
||||
if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace) &&
|
||||
Style.BraceWrapping.AfterControlStatement ==
|
||||
FormatStyle::BWACS_MultiLine)
|
||||
return 0;
|
||||
|
|
|
@ -2860,6 +2860,19 @@ TEST_F(FormatTest, MultiLineControlStatements) {
|
|||
" baz();\n"
|
||||
"}",
|
||||
format("try{foo();}catch(...){baz();}", Style));
|
||||
|
||||
Style.BraceWrapping.AfterFunction = true;
|
||||
Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_MultiLine;
|
||||
Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
|
||||
Style.ColumnLimit = 80;
|
||||
verifyFormat("void shortfunction() { bar(); }", Style);
|
||||
|
||||
Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
|
||||
verifyFormat("void shortfunction()\n"
|
||||
"{\n"
|
||||
" bar();\n"
|
||||
"}",
|
||||
Style);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, BeforeWhile) {
|
||||
|
|
Loading…
Reference in New Issue