sugak created this revision. sugak added reviewers: modocache, sammccall, arthur.j.odwyer. Herald added a project: clang. Herald added a subscriber: cfe-commits. sugak edited the summary of this revision.
// Before: co_yield* x; co_return* x; // After: co_yield *x; co_return *x; Add unit-test to cover these cases. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D71731 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ 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;"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ 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;"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits