From: Daniel Jasper Date: Thu, 23 Apr 2015 12:59:09 +0000 (+0000) Subject: clang-format: Allow splitting "= default" and "= delete". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a378d472a52fe1d0b23be4aa021ff2b7622af512;p=clang clang-format: Allow splitting "= default" and "= delete". Otherwise, this can violate the column limit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235592 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 60344021c5..c6ffd8a977 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index de46bba634..0f2545105e 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2497,6 +2497,14 @@ TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) { TEST_F(FormatTest, DoesNotBreakPureVirtualFunctionDefinition) { verifyFormat("virtual void write(ELFWriter *writerrr,\n" " OwningPtr &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) {