Skip to content

Commit 48b60d6

Browse files
bcardosolopeslanza
authored andcommitted
[CIR][CIRGen][NFC] Exceptions: refactor invoke checks to better align with CIR
1 parent 7ff2a25 commit 48b60d6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

clang/lib/CIR/CodeGen/CIRGenException.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,9 @@ CIRGenFunction::getEHDispatchBlock(EHScopeStack::stable_iterator si,
808808
return dispatchBlock;
809809
}
810810

811-
mlir::Operation *CIRGenFunction::getInvokeDestImpl() {
812-
assert(EHStack.requiresLandingPad());
813-
assert(!EHStack.empty());
811+
bool CIRGenFunction::isInvokeDest() {
812+
if (!EHStack.requiresLandingPad())
813+
return false;
814814

815815
// If exceptions are disabled/ignored and SEH is not in use, then there is no
816816
// invoke destination. SEH "works" even if exceptions are off. In practice,
@@ -819,13 +819,23 @@ mlir::Operation *CIRGenFunction::getInvokeDestImpl() {
819819
const LangOptions &LO = CGM.getLangOpts();
820820
if (!LO.Exceptions || LO.IgnoreExceptions) {
821821
if (!LO.Borland && !LO.MicrosoftExt)
822-
return nullptr;
822+
return false;
823823
if (!currentFunctionUsesSEHTry())
824-
return nullptr;
824+
return false;
825825
}
826826

827827
// CUDA device code doesn't have exceptions.
828828
if (LO.CUDA && LO.CUDAIsDevice)
829+
return false;
830+
831+
return true;
832+
}
833+
834+
mlir::Operation *CIRGenFunction::getInvokeDestImpl() {
835+
assert(EHStack.requiresLandingPad());
836+
assert(!EHStack.empty());
837+
838+
if (!isInvokeDest())
829839
return nullptr;
830840

831841
// Check the innermost scope for a cached landing pad. If this is

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ class CIRGenFunction : public CIRGenTypeCache {
17671767
// any other relevant information.
17681768
return getInvokeDestImpl();
17691769
}
1770+
bool isInvokeDest();
17701771

17711772
/// Takes the old cleanup stack size and emits the cleanup blocks
17721773
/// that have been added.

0 commit comments

Comments
 (0)