<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/83521>83521</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Regression: -fnon-call-exceptions Option No Longer Works as Expected from Clang 12 Onwards
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          yanwei1983
      </td>
    </tr>
</table>

<pre>
    I've encountered an issue with the `-fnon-call-exceptions` compiler option that seems to have regressed starting from Clang 12. This option was functional up to Clang 11, allowing exceptions to be thrown from signal handlers and caught by C++ catch blocks as expected. However, from Clang 12 onwards, this functionality appears to have been lost or broken.

### Description:

The `-fnon-call-exceptions` option is critical for my projects, as it allows exceptions to be thrown from signal handlers and then caught by surrounding C++ try-catch blocks. This functionality was working as expected up to and including Clang 11, but has ceased to work from Clang 12 onwards.

### Steps to Reproduce:

I have prepared a minimal example to demonstrate this issue, which can be found at [godbolt](https://godbolt.org/z/8fYM5nK91). This example works as expected when compiled with Clang 11 or earlier versions, where the exception thrown in the signal handler is caught by the C++ catch block. However, when compiled with Clang 12 or later, including the latest Clang 16, the exception is no longer caught as expected.

### Expected Behavior:

When compiled with `-fnon-call-exceptions`, any exceptions thrown in signal handlers should be able to be caught by C++ catch blocks.

### Actual Behavior:

Starting from Clang 12, compiling with `-fnon-call-exceptions` no longer allows exceptions thrown in signal handlers to be caught by C++ catch blocks.

### Request:

I am requesting assistance to either restore the previous functionality of `-fnon-call-exceptions` in the latest version of Clang (preferably Clang 17) or to provide guidance on a workaround or alternative approach to achieve the same functionality.

Thank you for your attention to this matter. I am looking forward to your guidance and assistance.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVt1u2zgTfRr6ZmBDpv8vfNE0n_EV-1OgLVDs5YgaWdxQpJYc2fE-_YKkHNup02CxQJAgIjU8c86cQ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