[libc-commits] [libc] [libc] Enabling code coverage via Linux syscalls (PR #213271)

via libc-commits libc-commits at lists.llvm.org
Fri Aug 21 11:03:25 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libc/src/__support/OSUtil/linux/syscall_wrappers/getpid.h libc/test/UnitTest/Coverage.h libc/src/__support/OSUtil/linux/syscall_wrappers/raise.h libc/test/UnitTest/ExecuteFunctionUnix.cpp libc/test/UnitTest/LibcTestMain.cpp --diff_from_common_commit
``````````

:warning:
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.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/__support/OSUtil/linux/syscall_wrappers/getpid.h b/libc/src/__support/OSUtil/linux/syscall_wrappers/getpid.h
index 6b1d2686c..044597a31 100644
--- a/libc/src/__support/OSUtil/linux/syscall_wrappers/getpid.h
+++ b/libc/src/__support/OSUtil/linux/syscall_wrappers/getpid.h
@@ -18,9 +18,7 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace linux_syscalls {
 
-LIBC_INLINE pid_t getpid() {
-  return syscall_impl<pid_t>(SYS_getpid);
-}
+LIBC_INLINE pid_t getpid() { return syscall_impl<pid_t>(SYS_getpid); }
 
 } // namespace linux_syscalls
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/UnitTest/Coverage.h b/libc/test/UnitTest/Coverage.h
index e142775c1..f9c2e76fb 100644
--- a/libc/test/UnitTest/Coverage.h
+++ b/libc/test/UnitTest/Coverage.h
@@ -106,8 +106,7 @@ extern "C" void write_raw_profile() {
 
   FixedSizeBuffer filename;
   char pid_buf[LIBC_NAMESPACE::IntegerToString<long>::buffer_size()];
-  auto pid_str =
-      LIBC_NAMESPACE::IntegerToString<long>::format_to(pid_buf, pid);
+  auto pid_str = LIBC_NAMESPACE::IntegerToString<long>::format_to(pid_buf, pid);
   if (!pid_str || !filename.append("libc_cov_") || !filename.append(*pid_str) ||
       !filename.append(".profraw")) {
     LIBC_NAMESPACE::linux_syscalls::munmap(profile_buffer, required_size);
diff --git a/libc/test/UnitTest/ExecuteFunctionUnix.cpp b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
index a97ebeaf6..f2d53cf21 100644
--- a/libc/test/UnitTest/ExecuteFunctionUnix.cpp
+++ b/libc/test/UnitTest/ExecuteFunctionUnix.cpp
@@ -68,7 +68,7 @@ int ProcessStatus::get_fatal_signal() {
 static void coverage_fatal_signal_handler(int sig) {
   if (write_raw_profile)
     write_raw_profile();
-  
+
   // Restore default signal handler
 #ifdef LIBC_FULL_BUILD
   struct sigaction sa = {};
@@ -77,7 +77,7 @@ static void coverage_fatal_signal_handler(int sig) {
 #else
   ::signal(sig, SIG_DFL);
 #endif
-  
+
   // Re-raise the signal
   LIBC_IMPL::kill(LIBC_IMPL::getpid(), sig);
 }
diff --git a/libc/test/UnitTest/LibcTestMain.cpp b/libc/test/UnitTest/LibcTestMain.cpp
index fb46ec450..a7e946171 100644
--- a/libc/test/UnitTest/LibcTestMain.cpp
+++ b/libc/test/UnitTest/LibcTestMain.cpp
@@ -65,4 +65,3 @@ TEST_MAIN(int argc, char **argv, char **envp) {
 #endif
   return result;
 }
-

``````````

</details>


https://github.com/llvm/llvm-project/pull/213271


More information about the libc-commits mailing list