[PATCH] D71731: [Format] fix dereference of pointers in co_yeld and co_return statements

2019-12-19 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Nice! Thanks for this. This looks good to me, but I'll defer to the other 
reviewers you specified, since I think they're more familiar with clang-format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71731/new/

https://reviews.llvm.org/D71731



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71731: [Format] fix dereference of pointers in co_yeld and co_return statements

2019-12-19 Thread Igor Sugak via Phabricator via cfe-commits
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