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" "};");