clang-format: Allow splitting "= default" and "= delete".

Otherwise, this can violate the column limit.

llvm-svn: 235592
This commit is contained in:
Daniel Jasper 2015-04-23 12:59:09 +00:00
parent d0be0a9897
commit caf84fe21e
2 changed files with 10 additions and 1 deletions

View File

@ -2063,7 +2063,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Left.is(tok::kw_operator))
return false;
if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) &&
Line.Type == LT_VirtualFunctionDecl)
return false;
if (Left.is(tok::l_paren) && Left.is(TT_AttributeParen))
return false;

View File

@ -2497,6 +2497,14 @@ TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {
TEST_F(FormatTest, DoesNotBreakPureVirtualFunctionDefinition) {
verifyFormat("virtual void write(ELFWriter *writerrr,\n"
" OwningPtr<FileOutputBuffer> &buffer) = 0;");
// Do break defaulted and deleted functions.
verifyFormat("virtual void ~Deeeeeeeestructor() =\n"
" default;",
getLLVMStyleWithColumns(40));
verifyFormat("virtual void ~Deeeeeeeestructor() =\n"
" delete;",
getLLVMStyleWithColumns(40));
}
TEST_F(FormatTest, BreaksStringLiteralsOnlyInDefine) {