GkvJwa wrote:

> @GkvJwa I don't understand the added message in your last comment. 
> [Previously](https://github.com/llvm/llvm-project/pull/172287#discussion_r2635384617)
>  you already identified the call stack which tells us how pushCleanup is 
> called. `NormalAndEHCleanup` does really mean it is a `NormalCleanup` + 
> `EHCleanup` so yes the code is executed -> thats really how the problematic 
> `seh.scope.begin` gets emitted for your case which causes the issue: 
> https://godbolt.org/z/hKW6vroeY .

What I'm trying to say is that with SEH enabled, `EmitCXXTemporary` in the 
`__try/__except` block should not actually be called.

`EmitCXXTemporary` executes `pushDestroy` to pass `NormalAndEHCleanup`
```
void CodeGenFunction::EmitCXXTemporary(const CXXTemporary *Temporary,
                                       QualType TempType,
                                       Address Ptr) {
  pushDestroy(NormalAndEHCleanup, Ptr, TempType, destroyCXXObject,
              /*useEHCleanup*/ true);
}
```

However, if we consider handling this within `pushCleanup`, Could it be 
misjudged as a normal use of `(pushCleanup + NormalAndEHCleanup)`?

This led me to wonder before if it was possible to make a judgment directly in 
this way.
```
void *EHScopeStack::pushCleanup(CleanupKind Kind, size_t Size) {
  ...
  if (CGF->getLangOpts().EHAsynch && IsEHCleanup && !IsLifetimeMarker &&
      CGF->getTarget().getCXXABI().isMicrosoft() && CGF->getInvokeDest()) {
      if (IsNormalCleanup) {
        CGF->CGM.getDiags().Report(CGF->CurFuncDecl->getLocation(),
                                   diag::err_seh_expected_handler);
      }
    }
    CGF->EmitSehCppScopeBegin();
  }
```

I may communicate via code in the future (you can do that too), as there might 
be some misunderstandings in the text.


https://github.com/llvm/llvm-project/pull/172287
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to