[clang] [WinEH] Also check object unwinding for enabling CXXExceptions(/ehs*) (PR #180959)

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 08:15:38 PST 2026


================
@@ -2228,8 +2228,10 @@ void CodeGenFunction::EmitAutoVarCleanups(const AutoVarEmission &emission) {
 
   // Check the type for a cleanup.
   if (QualType::DestructionKind dtorKind = D.needsDestruction(getContext())) {
-    // Check if we're in a SEH block with EHa, prevent it
-    if (getLangOpts().EHAsynch && currentFunctionUsesSEHTry())
+    // Check if we're in a SEH block with /EH, prevent it
+    // TODO: /EHs* differs from /EHa, the former may not be executed to this
+    // point.
----------------
GkvJwa wrote:

For example, when separating ehsc and eha, compile the following code snippet

```
void seh_unwinding() {
  __try {
  } __except (1) {
    HasCleanup x;
  }
}
```

When using ehsc, the functionCodeGenFunction::EmitAutoVarCleanups will not be called. But eha can

Therefore, most object unwinding can be blocked here when eha is enabled, ehs* may need to be blocked elsewhere

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


More information about the cfe-commits mailing list