[clang] [clang-tools-extra] [llvm] [LLVM][CLANG] Update signal-handling behavior to comply with POSIX (PR #169340)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 9 09:46:37 PST 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 inc,cpp,h,c -- clang/lib/Driver/Driver.cpp clang/test/Driver/crash-diagnostics-dir-3.c clang/test/Driver/crash-diagnostics-dir.c clang/test/Driver/crash-ir-repro.cpp clang/test/Driver/crash-report-clang-cl.cpp clang/test/Driver/crash-report-header.h clang/test/Driver/crash-report-spaces.c clang/test/Driver/crash-report-with-asserts.c clang/test/Driver/crash-report.cpp clang/test/Driver/emit-reproducer.c clang/test/Driver/output-file-cleanup.c clang/tools/driver/driver.cpp llvm/include/llvm/Support/InitLLVM.h llvm/include/llvm/Support/Signals.h llvm/lib/Support/CrashRecoveryContext.cpp llvm/lib/Support/InitLLVM.cpp llvm/lib/Support/Unix/Signals.inc --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/llvm/include/llvm/Support/InitLLVM.h b/llvm/include/llvm/Support/InitLLVM.h
index 1473026e2..6859964bd 100644
--- a/llvm/include/llvm/Support/InitLLVM.h
+++ b/llvm/include/llvm/Support/InitLLVM.h
@@ -39,7 +39,7 @@ public:
                     bool InstallPipeSignalExitHandler = true,
                     bool IsClandDriver = false);
   InitLLVM(int &Argc, char **&Argv, bool InstallPipeSignalExitHandler = true,
-                    bool IsClangDriver = false)
+           bool IsClangDriver = false)
       : InitLLVM(Argc, const_cast<const char **&>(Argv),
                  InstallPipeSignalExitHandler, IsClangDriver) {}
 
diff --git a/llvm/include/llvm/Support/Signals.h b/llvm/include/llvm/Support/Signals.h
index 22612a55b..9d8fa97eb 100644
--- a/llvm/include/llvm/Support/Signals.h
+++ b/llvm/include/llvm/Support/Signals.h
@@ -100,7 +100,8 @@ using SignalHandlerCallback = void (*)(void *);
 /// Add a function to be called when an abort/kill signal is delivered to the
 /// process. The handler can have a cookie passed to it to identify what
 /// instance of the handler it is.
-LLVM_ABI void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie, bool IsClangDriver = false);
+LLVM_ABI void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie,
+                               bool IsClangDriver = false);
 
 /// This function registers a function to be called when the user "interrupts"
 /// the program (typically by pressing ctrl-c).  When the user interrupts the
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index 248250cc5..795e9ab0b 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -73,8 +73,7 @@ using namespace llvm;
 using namespace llvm::sys;
 
 InitLLVM::InitLLVM(int &Argc, const char **&Argv,
-                   bool InstallPipeSignalExitHandler,
-                   bool IsClangDriver) {
+                   bool InstallPipeSignalExitHandler, bool IsClangDriver) {
 #ifndef NDEBUG
   static std::atomic<bool> Initialized{false};
   assert(!Initialized && "InitLLVM was already initialized!");
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 1d1cc9c91..ad387bc0f 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -505,9 +505,9 @@ void llvm::sys::DontRemoveFileOnSignal(StringRef Filename) {
 /// Add a function to be called when a signal is delivered to the process. The
 /// handler can have a cookie passed to it to identify what instance of the
 /// handler it is.
-void llvm::sys::AddSignalHandler(sys::SignalHandlerCallback FnPtr,
-                                 void *Cookie, bool IsClangDriver) {
-                                 // Signal-safe.
+void llvm::sys::AddSignalHandler(sys::SignalHandlerCallback FnPtr, void *Cookie,
+                                 bool IsClangDriver) {
+  // Signal-safe.
   insertSignalHandler(FnPtr, Cookie);
   RegisterHandlers(IsClangDriver);
 }

``````````

</details>


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


More information about the cfe-commits mailing list