What about override and final? What about ')' followed by an identifier (say `void f() OVERRIDE`)?
On Wed, May 22, 2013 at 1:28 AM, Daniel Jasper <[email protected]> wrote: > Author: djasper > Date: Wed May 22 03:28:26 2013 > New Revision: 182455 > > URL: http://llvm.org/viewvc/llvm-project?rev=182455&view=rev > Log: > Improve handling of trailing 'const'. > > Reduce the preference for breaking before a trailing 'const' according > to review comments on r182362. > > Modified: > cfe/trunk/lib/Format/TokenAnnotator.cpp > cfe/trunk/unittests/Format/FormatTest.cpp > > Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=182455&r1=182454&r2=182455&view=diff > > ============================================================================== > --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) > +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 22 03:28:26 2013 > @@ -959,6 +959,10 @@ unsigned TokenAnnotator::splitPenalty(co > return 150; > } > > + // Breaking before a trailing 'const' is bad. > + if (Left.is(tok::r_paren) && Right.is(tok::kw_const)) > + return 150; > + > // In for-loops, prefer breaking at ',' and ';'. > if (Line.First.is(tok::kw_for) && Left.is(tok::equal)) > return 4; > @@ -1165,6 +1169,11 @@ bool TokenAnnotator::canBreakBefore(cons > // change the "binding" behavior of a comment. > return false; > > + // We only break before r_brace if there was a corresponding break > before > + // the l_brace, which is tracked by BreakBeforeClosingBrace. > + if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater)) > + return false; > + > // Allow breaking after a trailing 'const', e.g. after a method > declaration, > // unless it is follow by ';', '{' or '='. > if (Left.is(tok::kw_const) && Left.Parent != NULL && > @@ -1174,10 +1183,6 @@ bool TokenAnnotator::canBreakBefore(cons > if (Right.is(tok::kw___attribute)) > return true; > > - // We only break before r_brace if there was a corresponding break > before > - // the l_brace, which is tracked by BreakBeforeClosingBrace. > - if (Right.isOneOf(tok::r_brace, tok::r_paren, tok::greater)) > - return false; > if (Left.is(tok::identifier) && Right.is(tok::string_literal)) > return true; > return (Left.isBinaryOperator() && Left.isNot(tok::lessless)) || > > Modified: cfe/trunk/unittests/Format/FormatTest.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182455&r1=182454&r2=182455&view=diff > > ============================================================================== > --- cfe/trunk/unittests/Format/FormatTest.cpp (original) > +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 22 03:28:26 2013 > @@ -1929,9 +1929,23 @@ TEST_F(FormatTest, BreaksFunctionDeclara > } > > TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { > - verifyFormat("void someLongFunction(int someLongParameter)\n" > - " const;", > - getLLVMStyleWithColumns(45)); > + verifyFormat("void someLongFunction(\n" > + " int someLongParameter) const {}", > + getLLVMStyleWithColumns(46)); > + FormatStyle Style = getGoogleStyle(); > + Style.ColumnLimit = 47; > + verifyFormat("void\n" > + "someLongFunction(int someLongParameter) const {\n}", > + getLLVMStyleWithColumns(47)); > + verifyFormat("void someLongFunction(\n" > + " int someLongParameter) const {}", > + Style); > + verifyFormat("LoooooongReturnType\n" > + "someLoooooooongFunction() const {}", > + getLLVMStyleWithColumns(47)); > + verifyFormat("LoooooongReturnType someLoooooooongFunction()\n" > + " const {}", > + Style); > > verifyFormat("void aaaaaaaaaaaa(int > aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" > " LOCKS_EXCLUDED(aaaaaaaaaaaaa);"); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
