r203466 - clang-format: Add spaces between lambdas and comments.
Sean Silva
silvas at purdue.edu
Fri Mar 14 14:26:14 PDT 2014
Thanks!
On Mon, Mar 10, 2014 at 11:06 AM, Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Mon Mar 10 10:06:25 2014
> New Revision: 203466
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203466&view=rev
> Log:
> clang-format: Add spaces between lambdas and comments.
>
> Before:
> void f() {
> bar([]() {}// Does not respect SpacesBeforeTrailingComments
> );
> }
>
> After:
> void f() {
> bar([]() {} // Does not respect SpacesBeforeTrailingComments
> );
> }
>
> This fixes llvm.org/PR19017.
>
> 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=203466&r1=203465&r2=203466&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
> +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Mar 10 10:06:25 2014
> @@ -1100,7 +1100,8 @@ void TokenAnnotator::calculateFormatting
> bool InFunctionDecl = Line.MightBeFunctionDecl;
> while (Current != NULL) {
> if (Current->Type == TT_LineComment) {
> - if (Current->Previous->BlockKind == BK_BracedInit)
> + if (Current->Previous->BlockKind == BK_BracedInit &&
> + Current->Previous->opensScope())
> Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 :
> 1;
> else
> Current->SpacesRequiredBefore =
> Style.SpacesBeforeTrailingComments;
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=203466&r1=203465&r2=203466&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Mar 10 10:06:25 2014
> @@ -7980,6 +7980,12 @@ TEST_F(FormatTest, FormatsLambdas) {
> verifyFormat("double &operator[](int i) { return 0; }\n"
> "int i;");
> verifyFormat("std::unique_ptr<int[]> foo() {}");
> +
> + // Other corner cases.
> + verifyFormat("void f() {\n"
> + " bar([]() {} // Did not respect
> SpacesBeforeTrailingComments\n"
> + " );\n"
> + "}");
> }
>
> TEST_F(FormatTest, FormatsBlocks) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140314/fb09adb1/attachment.html>
More information about the cfe-commits
mailing list