r357877 - [clang-format] Fix bug https://bugs.llvm.org/show_bug.cgi?id=41413

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 12 11:34:00 PDT 2019


Hi Owen,

FYI, putting a URL in the headline of the commit message takes up
space and doesn't really describe the fix to a casual reader. The
subject line of your Phabricator review looks like it would have
been perfectly fine to use for the commit as well.

Citing the bug in the body of the commit message is enough to let
people track down the original report, although even there we usually 
abbreviate it to 'PRnnnn' (so PR41413 in this example).

Thanks!
--paulr

> -----Original Message-----
> From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On Behalf Of
> Owen Pan via cfe-commits
> Sent: Sunday, April 07, 2019 5:06 PM
> To: cfe-commits at lists.llvm.org
> Subject: r357877 - [clang-format] Fix bug
> https://bugs.llvm.org/show_bug.cgi?id=41413
> 
> Author: owenpan
> Date: Sun Apr  7 14:05:52 2019
> New Revision: 357877
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=357877&view=rev
> Log:
> [clang-format] Fix bug https://bugs.llvm.org/show_bug.cgi?id=41413
> 
> Differential Revision: https://reviews.llvm.org/D60374
> 
> Modified:
>     cfe/trunk/lib/Format/ContinuationIndenter.cpp
>     cfe/trunk/unittests/Format/FormatTest.cpp
> 
> Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=357877&r1=357876
> &r2=357877&view=diff
> ==========================================================================
> ====
> --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
> +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Sun Apr  7 14:05:52 2019
> @@ -945,18 +945,24 @@ unsigned ContinuationIndenter::getNewLin
>        return State.Stack[State.Stack.size() - 2].LastSpace;
>      return State.FirstIndent;
>    }
> -  // Indent a closing parenthesis at the previous level if followed by a
> semi or
> -  // opening brace. This allows indentations such as:
> +  // Indent a closing parenthesis at the previous level if followed by a
> semi,
> +  // const, or opening brace. This allows indentations such as:
>    //     foo(
>    //       a,
>    //     );
> +  //     int Foo::getter(
> +  //         //
> +  //     ) const {
> +  //       return foo;
> +  //     }
>    //     function foo(
>    //       a,
>    //     ) {
>    //       code(); //
>    //     }
>    if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
> -      (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
> +      (!Current.Next ||
> +       Current.Next->isOneOf(tok::semi, tok::kw_const, tok::l_brace)))
>      return State.Stack[State.Stack.size() - 2].LastSpace;
>    if (NextNonComment->is(TT_TemplateString) && NextNonComment-
> >closesScope())
>      return State.Stack[State.Stack.size() - 2].LastSpace;
> 
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=357877&r1=357876&r2=
> 357877&view=diff
> ==========================================================================
> ====
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Sun Apr  7 14:05:52 2019
> @@ -12822,6 +12822,24 @@ TEST_F(FormatTest, ConfigurableContinuat
>              format("int i = longFunction(arg);", SixIndent));
>  }
> 
> +TEST_F(FormatTest, WrappedClosingParenthesisIndent) {
> +  FormatStyle Style = getLLVMStyle();
> +  verifyFormat(
> +      "int Foo::getter(\n"
> +      "    //\n"
> +      ") const {\n"
> +      "  return foo;\n"
> +      "}",
> +      Style);
> +  verifyFormat(
> +      "void Foo::setter(\n"
> +      "    //\n"
> +      ") {\n"
> +      "  foo = 1;\n"
> +      "}",
> +      Style);
> +}
> +
>  TEST_F(FormatTest, SpacesInAngles) {
>    FormatStyle Spaces = getLLVMStyle();
>    Spaces.SpacesInAngles = true;
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list