Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions clang/lib/Format/ContinuationIndenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,16 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
// name.
!Style.isJavaScript() && Previous.isNot(tok::kw_template) &&
CurrentState.BreakBeforeParameter) {
for (const auto *Tok = &Previous; Tok; Tok = Tok->Previous)
if (Tok->FirstAfterPPLine || Tok->is(TT_LineComment))
for (const auto *Tok = &Previous; Tok; Tok = Tok->Previous) {
if (Tok->is(TT_LineComment))
return false;
if (Tok->is(TT_TemplateCloser)) {
Tok = Tok->MatchingParen;
assert(Tok);
}
if (Tok->FirstAfterPPLine)
return false;
}

return true;
}
Expand Down
10 changes: 9 additions & 1 deletion clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8614,14 +8614,22 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
verifyFormat("extern \"C\" //\n"
" void f();");

FormatStyle Style = getLLVMStyle();
auto Style = getLLVMStyle();
Style.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}",
Style);
verifyFormat("void aaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
Style);

Style = getLLVMStyleWithColumns(45);
Style.PenaltyReturnTypeOnItsOwnLine = 400;
verifyFormat("template <bool abool, // a comment\n"
" bool anotherbool>\n"
"static inline std::pair<size_t, MyCustomType>\n"
"myfunc(const char *buf, const char *&err);",
Style);
}

TEST_F(FormatTest, DontBreakBeforeQualifiedOperator) {
Expand Down