@@ -1616,43 +1616,17 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,
1616
1616
assert (declRef);
1617
1617
1618
1618
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);
1626
1620
booleanTestValue = emitUnwrapIntegerResult (expr, booleanTestValue);
1627
1621
booleanTestLoc = expr;
1628
1622
1629
1623
// Ensure that function declarations for each function associated with
1630
1624
// 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
+ });
1650
1629
1651
- SILSymbolVisitorOptions opts;
1652
- opts.VisitMembers = false ;
1653
- auto visitorCtx =
1654
- SILSymbolVisitorContext (getModule ().getSwiftModule (), opts);
1655
- SymbolVisitor (SGM).visitDecl (decl, visitorCtx);
1656
1630
break ;
1657
1631
}
1658
1632
}
0 commit comments