Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1185,7 +1185,8 @@ } break; case tok::arrow: - if (Tok->Previous && Tok->Previous->is(tok::kw_noexcept)) + if (Tok->isNot(TT_LambdaArrow) && Tok->Previous && + Tok->Previous->is(tok::kw_noexcept)) Tok->setType(TT_TrailingReturnArrow); break; default: Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -21338,6 +21338,7 @@ verifyFormat("int c = []() -> int * { return 2; }();\n"); verifyFormat("int c = []() -> vector { return {2}; }();\n"); verifyFormat("Foo([]() -> std::vector { return {2}; }());"); + verifyFormat("foo([]() noexcept -> int {});"); verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};"); verifyGoogleFormat("auto a = [&b, c](D* d) -> pair {};"); verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");