Skip to content

Commit

Permalink
[CIR][CIRGen][Exceptions] Complete buildCatchDispatchBlock
Browse files Browse the repository at this point in the history
Doesn't do a lot of things compared to LLVM traditional codegen, one
more step towards basic exception support. No testcase possible just yet.
  • Loading branch information
bcardosolopes authored and lanza committed Oct 12, 2024
1 parent f58afc4 commit f34f2ab
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,28 @@ static void buildCatchDispatchBlock(CIRGenFunction &CGF,
return;
}

llvm_unreachable("NYI");
// In traditional LLVM codegen, the right handler is selected (with calls to
// eh_typeid_for) and the selector value is loaded. After that, blocks get
// connected for later codegen. In CIR, these are all implicit behaviors of
// cir.catch - not a lot of work to do.
//
// Test against each of the exception types we claim to catch.
for (unsigned i = 0, e = catchScope.getNumHandlers();; ++i) {
assert(i < e && "ran off end of handlers!");
const EHCatchScope::Handler &handler = catchScope.getHandler(i);

auto typeValue = handler.Type.RTTI;
assert(handler.Type.Flags == 0 && "catch handler flags not supported");
assert(typeValue && "fell into catch-all case!");
// Check for address space mismatch: if (typeValue->getType() != argTy)
assert(!UnimplementedFeature::addressSpace());

// If this is the last handler, we're at the end, and the next
// block is the block for the enclosing EH scope. Make sure to call
// getEHDispatchBlock for caching it.
if (i + 1 == e)
(void)CGF.getEHDispatchBlock(catchScope.getEnclosingEHScope());
}
}

void CIRGenFunction::enterCXXTryStmt(const CXXTryStmt &S,
Expand Down

0 comments on commit f34f2ab

Please sign in to comment.