[PATCH] D71731: [Format] fix dereference of pointers in co_yeld and co_return statements
Igor Sugak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 19 15:54:24 PST 2019
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71731.234800.patch
Type: text/x-patch
Size: 1372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191219/61804a80/attachment.bin>
More information about the cfe-commits
mailing list