diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1766,7 +1766,8 @@ if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace, tok::comma, tok::semi, tok::kw_return, tok::colon, tok::equal, tok::kw_delete, tok::kw_sizeof, - tok::kw_throw) || + tok::kw_throw, tok::kw_co_return, + tok::kw_co_yield) || PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr, TT_UnaryOperator, TT_CastRParen)) return TT_UnaryOperator; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -7223,6 +7223,8 @@ verifyIndependentOfContext("return 10 * b;"); verifyIndependentOfContext("return *b * *c;"); verifyIndependentOfContext("return a & ~b;"); + verifyIndependentOfContext("co_yield *b * *c;"); + verifyIndependentOfContext("co_return *b * *c;"); verifyIndependentOfContext("f(b ? *c : *d);"); verifyIndependentOfContext("int a = b ? *c : *d;"); verifyIndependentOfContext("*b = a;");