Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Format/TokenAnnotator.cpp
Show First 20 Lines • Show All 5,009 Lines • ▼ Show 20 Lines | bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, | ||||
if (Right.is(tok::r_brace)) | if (Right.is(tok::r_brace)) | ||||
return Right.MatchingParen && Right.MatchingParen->is(BK_Block); | return Right.MatchingParen && Right.MatchingParen->is(BK_Block); | ||||
// We only break before r_paren if we're in a block indented context. | // We only break before r_paren if we're in a block indented context. | ||||
if (Right.is(tok::r_paren)) { | if (Right.is(tok::r_paren)) { | ||||
if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent || | if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent || | ||||
!Right.MatchingParen) { | !Right.MatchingParen) { | ||||
return false; | return false; | ||||
} | } | ||||
auto Next = Right.Next; | |||||
if (Next && Next->is(tok::r_paren)) | |||||
Next = Next->Next; | |||||
if (Next && Next->is(tok::l_paren)) | |||||
return false; | |||||
owenpan: Can we simply add the above and leave the original `return` statement on line 5009 unchanged? | |||||
Yes this seems to work. I'll push a diff shortly along with reverting the EXPECT_EQ outside of my new tests. gedare: Yes this seems to work. I'll push a diff shortly along with reverting the EXPECT_EQ outside of… | |||||
const FormatToken *Previous = Right.MatchingParen->Previous; | const FormatToken *Previous = Right.MatchingParen->Previous; | ||||
return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf())); | return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf())); | ||||
} | } | ||||
Please follow the convention on comments as seen on surrounding lines (i.e. use proper sentences with capitalization and a full stop at the end) rymiel: Please follow the convention on comments as seen on surrounding lines (i.e. use proper… | |||||
// Allow breaking after a trailing annotation, e.g. after a method | // Allow breaking after a trailing annotation, e.g. after a method | ||||
// declaration. | // declaration. | ||||
if (Left.is(TT_TrailingAnnotation)) { | if (Left.is(TT_TrailingAnnotation)) { | ||||
return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren, | return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren, | ||||
This is horrible to read. Could you split this into multiple statements? Maybe with lambdas, I don't know. But I have no intention to ever understand that condition. HazardyKnusperkeks: This is horrible to read.
Could you split this into multiple statements? Maybe with lambdas, I… | |||||
Sure. I was just following the prevailing style in this code base. I'll refactor. gedare: Sure. I was just following the prevailing style in this code base. I'll refactor. | |||||
No problem. We have some of this occurrences. HazardyKnusperkeks: > Sure. I was just following the prevailing style in this code base. I'll refactor.
No problem. | |||||
tok::less, tok::coloncolon); | tok::less, tok::coloncolon); | ||||
} | } | ||||
if (Right.is(tok::kw___attribute) || | if (Right.is(tok::kw___attribute) || | ||||
(Right.is(tok::l_square) && Right.is(TT_AttributeSquare))) { | (Right.is(tok::l_square) && Right.is(TT_AttributeSquare))) { | ||||
return !Left.is(TT_AttributeSquare); | return !Left.is(TT_AttributeSquare); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |
Can we simply add the above and leave the original return statement on line 5009 unchanged?