=?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com>, =?utf-8?q?Tomáš?= Slanina <itzexpoe...@gmail.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/154...@github.com>
================ @@ -574,6 +580,82 @@ class LineJoiner { return 0; } + unsigned tryMergeRecord(ArrayRef<AnnotatedLine *>::const_iterator I, + ArrayRef<AnnotatedLine *>::const_iterator E, + unsigned Limit) { + const auto *Line = I[0]; + const auto *NextLine = I[1]; + + auto GetRelevantAfterOption = [&](const FormatToken *Tok) { + switch (Tok->getType()) { + case TT_StructLBrace: + return Style.BraceWrapping.AfterStruct; + case TT_ClassLBrace: + return Style.BraceWrapping.AfterClass; + case TT_UnionLBrace: + return Style.BraceWrapping.AfterUnion; + default: + return false; + }; + }; + + // Current line begins both record and block, brace was not wrapped. + if (Line->Last->isOneOf(TT_StructLBrace, TT_ClassLBrace, TT_UnionLBrace)) { + auto TryMergeShortRecord = [&] { + switch (Style.AllowShortRecordOnASingleLine) { + case FormatStyle::SRS_Never: + return false; + case FormatStyle::SRS_EmptyIfAttached: + case FormatStyle::SRS_Empty: + return NextLine->First->is(tok::r_brace); + case FormatStyle::SRS_Always: + return true; + } + }; + + if (Style.AllowShortRecordOnASingleLine != FormatStyle::SRS_Never && + (!GetRelevantAfterOption(Line->Last) || ---------------- owenca wrote: ```suggestion (!WrapLBrace(Line->Last->getType()) || ``` https://github.com/llvm/llvm-project/pull/154580 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits