[PATCH] D114859: [clang-format] Add better support for co-routinues

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 1 03:55:52 PST 2021


ChuanqiXu added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:22735
+  verifyFormat("co_await a; // comment");
+  verifyFormat("void test0() { co_await a; }");
+}
----------------
It may be worth to add following tests:
```
co_await co_await co_await foo();
co_await foo().bar();
co_await [this](int a, int b) -> Task {\n
    co_return co_await foo();\n
}(x, y);
co_await [this]() -> Task { co_return x; }
```



================
Comment at: clang/unittests/Format/FormatTest.cpp:22748-22749
+TEST_F(FormatTest, CoRoutinereturn) {
+  verifyFormat("int x = co_return foo();");
+  verifyFormat("int x = (co_return foo());");
+  verifyFormat("co_return (42);");
----------------
These two statements looks invalid.


================
Comment at: clang/unittests/Format/FormatTest.cpp:22752
+  verifyFormat("co_return;");
+  verifyFormat("co_return {};");
+}
----------------
I think it would be better to add two tests:
```
co_return x;
co_return co_await foo();
co_return co_yield foo();
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114859



More information about the cfe-commits mailing list