This revision was automatically updated to reflect the committed changes. Closed by commit rL373746: [clang-format] [PR42417] clang-format inserts a space after '->' for operator->… (authored by paulhoad, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D68242?vs=222487&id=223203#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D68242/new/ https://reviews.llvm.org/D68242 Files: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -1393,7 +1393,9 @@ Style.Language == FormatStyle::LK_Java) { Current.Type = TT_LambdaArrow; } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && - Current.NestingLevel == 0) { + Current.NestingLevel == 0 && + !Current.Previous->is(tok::kw_operator)) { + // not auto operator->() -> xxx; Current.Type = TT_TrailingReturnArrow; TrailingReturnFound = true; } else if (Current.is(tok::star) || Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -4956,6 +4956,10 @@ TEST_F(FormatTest, TrailingReturnType) { verifyFormat("auto foo() -> int;\n"); + // correct trailing return type spacing + verifyFormat("auto operator->() -> int;\n"); + verifyFormat("auto operator++(int) -> int;\n"); + verifyFormat("struct S {\n" " auto bar() const -> int;\n" "};");
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -1393,7 +1393,9 @@ Style.Language == FormatStyle::LK_Java) { Current.Type = TT_LambdaArrow; } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && - Current.NestingLevel == 0) { + Current.NestingLevel == 0 && + !Current.Previous->is(tok::kw_operator)) { + // not auto operator->() -> xxx; Current.Type = TT_TrailingReturnArrow; TrailingReturnFound = true; } else if (Current.is(tok::star) || Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -4956,6 +4956,10 @@ TEST_F(FormatTest, TrailingReturnType) { verifyFormat("auto foo() -> int;\n"); + // correct trailing return type spacing + verifyFormat("auto operator->() -> int;\n"); + verifyFormat("auto operator++(int) -> int;\n"); + verifyFormat("struct S {\n" " auto bar() const -> int;\n" "};");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits