Skip to content

Conversation

@aaupov
Copy link
Contributor

@aaupov aaupov commented Nov 12, 2025

No description provided.

Created using spr 1.3.4
@aaupov aaupov closed this Nov 12, 2025
@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp,h -- bolt/test/X86/Inputs/test_coro.cpp bolt/include/bolt/Profile/YAMLProfileWriter.h bolt/lib/Profile/DataAggregator.cpp bolt/lib/Profile/YAMLProfileWriter.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/bolt/test/X86/Inputs/test_coro.cpp b/bolt/test/X86/Inputs/test_coro.cpp
index eba662771..9d44bd464 100644
--- a/bolt/test/X86/Inputs/test_coro.cpp
+++ b/bolt/test/X86/Inputs/test_coro.cpp
@@ -1,72 +1,71 @@
-#include <iostream>
 #include <coroutine>
-#include <thread>
-#include <queue>
 #include <functional>
+#include <iostream>
+#include <queue>
+#include <thread>
 
 std::queue<std::function<bool()>> task_queue;
 
 struct co_sleep {
-    co_sleep(int n) : delay{n} {}
+  co_sleep(int n) : delay{n} {}
 
-    constexpr bool await_ready() const noexcept { return false; }
+  constexpr bool await_ready() const noexcept { return false; }
 
-    void await_suspend(std::coroutine_handle<> h) const noexcept {
-        auto start = std::chrono::steady_clock::now();
-        task_queue.push([start, h, d = delay] {
-            if (decltype(start)::clock::now() - start > d) {
-                h.resume();
-                return true;
-            } else {
-                return false;
-            }
-        });
-    }
+  void await_suspend(std::coroutine_handle<> h) const noexcept {
+    auto start = std::chrono::steady_clock::now();
+    task_queue.push([start, h, d = delay] {
+      if (decltype(start)::clock::now() - start > d) {
+        h.resume();
+        return true;
+      } else {
+        return false;
+      }
+    });
+  }
 
-    void await_resume() const noexcept {}
+  void await_resume() const noexcept {}
 
-    std::chrono::milliseconds delay;
+  std::chrono::milliseconds delay;
 };
 
-
 struct Task {
-    struct promise_type {
-        promise_type() = default;
-        Task get_return_object() { return {}; }
-        std::suspend_never initial_suspend() { return {}; }
-        std::suspend_always final_suspend() noexcept { return {}; }
-        void unhandled_exception() {}
-    };
+  struct promise_type {
+    promise_type() = default;
+    Task get_return_object() { return {}; }
+    std::suspend_never initial_suspend() { return {}; }
+    std::suspend_always final_suspend() noexcept { return {}; }
+    void unhandled_exception() {}
+  };
 };
 
 Task foo1() noexcept {
-    std::cout << "1. hello from foo1" << std::endl;
-    for (int i = 0; i < 10; ++i) {
-        co_await co_sleep{10};
-        std::cout << "2. hello from foo1" << std::endl;
-    }
+  std::cout << "1. hello from foo1" << std::endl;
+  for (int i = 0; i < 10; ++i) {
+    co_await co_sleep{10};
+    std::cout << "2. hello from foo1" << std::endl;
+  }
 }
 
 Task foo2() noexcept {
-    std::cout << "1. hello from foo2" << std::endl;
-    for (int i = 0; i < 10; ++i) {
-        co_await co_sleep{10};
-        std::cout << "2. hello from foo2" << std::endl;
-    }
+  std::cout << "1. hello from foo2" << std::endl;
+  for (int i = 0; i < 10; ++i) {
+    co_await co_sleep{10};
+    std::cout << "2. hello from foo2" << std::endl;
+  }
 }
 
-//call foo
+// call foo
 int main() {
-    foo1();
-    foo2();
-
-    while (!task_queue.empty()) {
-        auto task = task_queue.front();
-        if (!task()) {
-            task_queue.push(task);
-        }
-        task_queue.pop();
+  foo1();
+  foo2();
 
-        std::this_thread::sleep_for(std::chrono::milliseconds(10));
+  while (!task_queue.empty()) {
+    auto task = task_queue.front();
+    if (!task()) {
+      task_queue.push(task);
     }
+    task_queue.pop();
+
+    std::this_thread::sleep_for(std::chrono::milliseconds(10));
+  }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants