@@ -342,6 +342,12 @@ static BeginBorrowInst *hasOnlyBorrowingNonDestroyUse(SILValue searchValue) {
342342 return result;
343343}
344344
345+ namespace {
346+
347+ constexpr StringLiteral UnknownDeclString = " <unknown decl>" ;
348+
349+ } // namespace
350+
345351SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper (
346352 SILValue searchValue, ValueSet &visitedValues) {
347353 assert (searchValue);
@@ -552,15 +558,19 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
552558
553559 auto getNamePathComponentFromCallee = [&](FullApplySite call) -> SILValue {
554560 // Use the name of the property being accessed if we can get to it.
555- if (isa<FunctionRefBaseInst>(call.getCallee ()) ||
556- isa<MethodInst>(call.getCallee ())) {
557- if (call.getSubstCalleeType ()->hasSelfParam ()) {
561+ if (call.getSubstCalleeType ()->hasSelfParam ()) {
562+ if (auto *f = dyn_cast<FunctionRefBaseInst>(call.getCallee ())) {
563+ if (auto dc = f->getInitiallyReferencedFunction ()->getDeclContext ()) {
564+ variableNamePath.push_back (getNameFromDecl (dc->getAsDecl ()));
565+ return call.getSelfArgument ();
566+ }
567+ }
568+
569+ if (auto *mi = dyn_cast<MethodInst>(call.getCallee ())) {
558570 variableNamePath.push_back (
559- call. getCallee ()-> getDefiningInstruction ( ));
571+ getNameFromDecl (mi-> getMember (). getDecl () ));
560572 return call.getSelfArgument ();
561573 }
562-
563- return SILValue ();
564574 }
565575
566576 return SILValue ();
@@ -655,7 +665,7 @@ StringRef VariableNameInferrer::getNameFromDecl(Decl *d) {
655665 }
656666 }
657667
658- return " <unknown decl> " ;
668+ return UnknownDeclString ;
659669}
660670
661671void VariableNameInferrer::popSingleVariableName () {
@@ -666,29 +676,7 @@ void VariableNameInferrer::popSingleVariableName() {
666676 return ;
667677 }
668678
669- if (std::holds_alternative<SILInstruction *>(next)) {
670- auto *inst = std::get<SILInstruction *>(next);
671-
672- if (auto f = dyn_cast<FunctionRefBaseInst>(inst)) {
673- if (auto dc = f->getInitiallyReferencedFunction ()->getDeclContext ()) {
674- resultingString += getNameFromDecl (dc->getAsDecl ());
675- return ;
676- }
677-
678- resultingString += " <unknown decl>" ;
679- return ;
680- }
681-
682- if (auto m = dyn_cast<MethodInst>(inst)) {
683- resultingString += getNameFromDecl (m->getMember ().getDecl ());
684- return ;
685- }
686-
687- resultingString += " <unknown decl>" ;
688- return ;
689- }
690-
691- resultingString += " <unknown decl>" ;
679+ resultingString += UnknownDeclString;
692680}
693681
694682void VariableNameInferrer::drainVariableNamePath () {
0 commit comments