@@ -363,20 +363,16 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
363363 dispatcher_.emit (DiscardAssignmentExprsTrap{label});
364364 }
365365
366- void visitClosureExpr (swift::ClosureExpr* expr) {
367- auto label = dispatcher_.assignNewLabel (expr);
368- assert (expr->getBody () && " ClosureExpr has getBody()" );
369- auto bodyLabel = dispatcher_.fetchLabel (expr->getBody ());
370- dispatcher_.emit (ClosureExprsTrap{label, bodyLabel});
371- emitAbstractClosureExpr (expr, label);
366+ codeql::ClosureExpr translateClosureExpr (const swift::ClosureExpr& expr) {
367+ ClosureExpr entry{dispatcher_.assignNewLabel (expr)};
368+ fillAbstractClosureExpr (expr, entry);
369+ return entry;
372370 }
373371
374- void visitAutoClosureExpr (swift::AutoClosureExpr* expr) {
375- auto label = dispatcher_.assignNewLabel (expr);
376- assert (expr->getBody () && " AutoClosureExpr has getBody()" );
377- auto bodyLabel = dispatcher_.fetchLabel (expr->getBody ());
378- dispatcher_.emit (AutoClosureExprsTrap{label, bodyLabel});
379- emitAbstractClosureExpr (expr, label);
372+ codeql::AutoClosureExpr translateAutoClosureExpr (const swift::AutoClosureExpr& expr) {
373+ AutoClosureExpr entry{dispatcher_.assignNewLabel (expr)};
374+ fillAbstractClosureExpr (expr, entry);
375+ return entry;
380376 }
381377
382378 void visitCoerceExpr (swift::CoerceExpr* expr) {
@@ -536,14 +532,12 @@ class ExprVisitor : public AstVisitorBase<ExprVisitor> {
536532 }
537533
538534 private:
539- void emitAbstractClosureExpr (swift::AbstractClosureExpr* expr,
540- TrapLabel<AbstractClosureExprTag> label) {
541- assert (expr->getParameters () && " AbstractClosureExpr has getParameters()" );
542- auto params = expr->getParameters ();
543- for (auto i = 0u ; i < params->size (); ++i) {
544- dispatcher_.emit (
545- AbstractClosureExprParamsTrap{label, i, dispatcher_.fetchLabel (params->get (i))});
546- }
535+ void fillAbstractClosureExpr (const swift::AbstractClosureExpr& expr,
536+ codeql::AbstractClosureExpr& entry) {
537+ assert (expr.getParameters () && " AbstractClosureExpr has getParameters()" );
538+ assert (expr.getBody () && " AbstractClosureExpr has getBody()" );
539+ entry.params = dispatcher_.fetchRepeatedLabels (*expr.getParameters ());
540+ entry.body = dispatcher_.fetchLabel (expr.getBody ());
547541 }
548542
549543 TrapLabel<ArgumentTag> emitArgument (const swift::Argument& arg) {
0 commit comments