@@ -1616,43 +1616,17 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,
16161616 assert (declRef);
16171617
16181618 auto decl = declRef.getDecl ();
1619- getModule ().addHasSymbolDecl (decl);
1620-
1621- SILFunction *silFn = SGM.getFunction (
1622- SILDeclRef (decl->getHasSymbolQueryDecl (), SILDeclRef::Kind::Func),
1623- NotForDefinition);
1624- SILValue fnRef = B.createFunctionRefFor (loc, silFn);
1625- booleanTestValue = B.createApply (loc, fnRef, {}, {});
1619+ booleanTestValue = B.createHasSymbol (expr, decl);
16261620 booleanTestValue = emitUnwrapIntegerResult (expr, booleanTestValue);
16271621 booleanTestLoc = expr;
16281622
16291623 // Ensure that function declarations for each function associated with
16301624 // the decl are emitted so that they can be referenced during IRGen.
1631- class SymbolVisitor : public SILSymbolVisitor {
1632- SILGenModule &SGM;
1633-
1634- public:
1635- SymbolVisitor (SILGenModule &SGM) : SGM{SGM} {};
1636-
1637- void addFunction (SILDeclRef declRef) override {
1638- (void )SGM.getFunction (declRef, NotForDefinition);
1639- }
1640-
1641- virtual void addFunction (StringRef name, SILDeclRef declRef) override {
1642- // The kinds of functions which go through this callback (e.g.
1643- // differentiability witnesses) can't be forward declared with a
1644- // SILDeclRef alone. For now, just ignore them.
1645- //
1646- // Ideally, this callback will be removed entirely in favor of
1647- // SILDeclRef being able to represent all function variants.
1648- }
1649- };
1625+ enumerateFunctionsForHasSymbol (
1626+ getModule (), decl, [this ](SILDeclRef declRef) {
1627+ (void )SGM.getFunction (declRef, NotForDefinition);
1628+ });
16501629
1651- SILSymbolVisitorOptions opts;
1652- opts.VisitMembers = false ;
1653- auto visitorCtx =
1654- SILSymbolVisitorContext (getModule ().getSwiftModule (), opts);
1655- SymbolVisitor (SGM).visitDecl (decl, visitorCtx);
16561630 break ;
16571631 }
16581632 }
0 commit comments