[cfe-commits] r172718 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Jordan Rose
jordan_rose at apple.com
Thu Jan 17 09:12:21 PST 2013
This should probably apply to trailing volatile as well (although that is ever so rarely used).
In C++11, a trailing & or && should probably be kept on the same line as a trailing const.
On Jan 17, 2013, at 5:31 , Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Thu Jan 17 07:31:52 2013
> New Revision: 172718
>
> URL: http://llvm.org/viewvc/llvm-project?rev=172718&view=rev
> Log:
> Allow breaking after the trailing const after a function declaration.
>
> Before:
> void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
> aaaaaaaaaaaaa);
>
> After:
> void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const
> GUARDED_BY(aaaaaaaaaaaaa);
>
> Modified:
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
>
> Modified: cfe/trunk/lib/Format/Format.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172718&r1=172717&r2=172718&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Format/Format.cpp (original)
> +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 17 07:31:52 2013
> @@ -1390,6 +1390,13 @@
> // change the "binding" behavior of a comment.
> 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 &&
> + Left.Parent->is(tok::r_paren))
> + return Right.isNot(tok::l_brace) && Right.isNot(tok::semi) &&
> + Right.isNot(tok::equal);
> +
> // We only break before r_brace if there was a corresponding break before
> // the l_brace, which is tracked by BreakBeforeClosingBrace.
> if (Right.is(tok::r_brace))
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172718&r1=172717&r2=172718&view=diff
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 17 07:31:52 2013
> @@ -899,6 +899,10 @@
> TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {
> verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
> " GUARDED_BY(aaaaaaaaaaaaa);");
> + verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
> + " GUARDED_BY(aaaaaaaaaaaaa);");
> + verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
> + " GUARDED_BY(aaaaaaaaaaaaa) {}");
> }
>
> TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list