@@ -2321,56 +2321,6 @@ static mlir::Value callBeginCatch(CIRGenFunction &cgf, mlir::Type paramTy,
23212321 return catchParam.getParam ();
23222322}
23232323
2324- // / A "special initializer" callback for initializing a catch
2325- // / parameter during catch initialization.
2326- static void initCatchParam (CIRGenFunction &cgf, const VarDecl &catchParam,
2327- Address paramAddr, SourceLocation loc) {
2328- CanQualType catchType =
2329- cgf.cgm .getASTContext ().getCanonicalType (catchParam.getType ());
2330- // If we're catching by reference, we can just cast the object
2331- // pointer to the appropriate pointer.
2332- if (isa<ReferenceType>(catchType)) {
2333- cgf.cgm .errorNYI (loc, " initCatchParam: ReferenceType" );
2334- return ;
2335- }
2336-
2337- // Scalars and complexes.
2338- cir::TypeEvaluationKind tek = cgf.getEvaluationKind (catchType);
2339- if (tek != cir::TEK_Aggregate) {
2340- // Notes for LLVM lowering:
2341- // If the catch type is a pointer type, __cxa_begin_catch returns
2342- // the pointer by value.
2343- if (catchType->hasPointerRepresentation ()) {
2344- cgf.cgm .errorNYI (loc, " initCatchParam: hasPointerRepresentation" );
2345- return ;
2346- }
2347-
2348- mlir::Type cirCatchTy = cgf.convertTypeForMem (catchType);
2349- mlir::Value catchParam =
2350- callBeginCatch (cgf, cgf.getBuilder ().getPointerTo (cirCatchTy), false );
2351- LValue srcLV = cgf.makeNaturalAlignAddrLValue (catchParam, catchType);
2352- LValue destLV = cgf.makeAddrLValue (paramAddr, catchType);
2353- switch (tek) {
2354- case cir::TEK_Complex: {
2355- cgf.cgm .errorNYI (loc, " initCatchParam: cir::TEK_Complex" );
2356- return ;
2357- }
2358- case cir::TEK_Scalar: {
2359- auto exnLoad = cgf.emitLoadOfScalar (srcLV, loc);
2360- cgf.emitStoreOfScalar (exnLoad, destLV, /* isInit=*/ true );
2361- return ;
2362- }
2363- case cir::TEK_Aggregate:
2364- llvm_unreachable (" evaluation kind filtered out!" );
2365- }
2366-
2367- // Otherwise, it returns a pointer into the exception object.
2368- llvm_unreachable (" bad evaluation kind" );
2369- }
2370-
2371- cgf.cgm .errorNYI (loc, " initCatchParam: cir::TEK_Aggregate" );
2372- }
2373-
23742324// / Begins a catch statement by initializing the catch variable and
23752325// / calling __cxa_begin_catch.
23762326void CIRGenItaniumCXXABI::emitBeginCatch (CIRGenFunction &cgf,
@@ -2405,27 +2355,5 @@ void CIRGenItaniumCXXABI::emitBeginCatch(CIRGenFunction &cgf,
24052355 return ;
24062356 }
24072357
2408- auto getCatchParamAllocaIP = [&]() {
2409- auto currIns = cgf.getBuilder ().saveInsertionPoint ();
2410- mlir::Operation *currParent = currIns.getBlock ()->getParentOp ();
2411-
2412- mlir::Block *insertBlock = nullptr ;
2413- if (auto scopeOp = currParent->getParentOfType <cir::ScopeOp>()) {
2414- insertBlock = &scopeOp.getScopeRegion ().getBlocks ().back ();
2415- } else if (auto fnOp = currParent->getParentOfType <cir::FuncOp>()) {
2416- insertBlock = &fnOp.getRegion ().getBlocks ().back ();
2417- } else {
2418- llvm_unreachable (" unknown outermost scope-like parent" );
2419- }
2420- return cgf.getBuilder ().getBestAllocaInsertPoint (insertBlock);
2421- };
2422-
2423- // Emit the local. Make sure the alloca's superseed the current scope, since
2424- // these are going to be consumed by `cir.catch`, which is not within the
2425- // current scope.
2426- CIRGenFunction::AutoVarEmission var =
2427- cgf.emitAutoVarAlloca (*catchParam, getCatchParamAllocaIP ());
2428- initCatchParam (cgf, *catchParam, var.getObjectAddress (cgf),
2429- catchStmt->getBeginLoc ());
2430- cgf.emitAutoVarCleanups (var);
2358+ cgf.cgm .errorNYI (" emitBeginCatch: catch with exception decl" );
24312359}
0 commit comments