[clang-format] Merge inline short functions for BS_Whitesmiths (#134473)
Fix #126747
This commit is contained in:
parent
55ff96abfa
commit
aaaeb86ace
@ -316,8 +316,13 @@ private:
|
||||
const AnnotatedLine *Line = nullptr;
|
||||
for (auto J = I - 1; J >= AnnotatedLines.begin(); --J) {
|
||||
assert(*J);
|
||||
if (!(*J)->InPPDirective && !(*J)->isComment() &&
|
||||
(*J)->Level < TheLine->Level) {
|
||||
if ((*J)->InPPDirective || (*J)->isComment() ||
|
||||
(*J)->Level > TheLine->Level) {
|
||||
continue;
|
||||
}
|
||||
if ((*J)->Level < TheLine->Level ||
|
||||
(Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
|
||||
(*J)->First->is(tok::l_brace))) {
|
||||
Line = *J;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -15142,6 +15142,13 @@ TEST_F(FormatTest, PullInlineOnlyFunctionDefinitionsIntoSingleLine) {
|
||||
"}",
|
||||
MergeInlineOnly);
|
||||
|
||||
MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Whitesmiths;
|
||||
verifyFormat("class Foo\n"
|
||||
" {\n"
|
||||
" void f() { foo(); }\n"
|
||||
" };",
|
||||
MergeInlineOnly);
|
||||
|
||||
// Also verify behavior when BraceWrapping.AfterFunction = true
|
||||
MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
|
||||
MergeInlineOnly.BraceWrapping.AfterFunction = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user