@@ -342,6 +342,12 @@ static BeginBorrowInst *hasOnlyBorrowingNonDestroyUse(SILValue searchValue) {
342
342
return result;
343
343
}
344
344
345
+ namespace {
346
+
347
+ constexpr StringLiteral UnknownDeclString = " <unknown decl>" ;
348
+
349
+ } // namespace
350
+
345
351
SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper (
346
352
SILValue searchValue, ValueSet &visitedValues) {
347
353
assert (searchValue);
@@ -552,15 +558,19 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
552
558
553
559
auto getNamePathComponentFromCallee = [&](FullApplySite call) -> SILValue {
554
560
// 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 ())) {
558
570
variableNamePath.push_back (
559
- call. getCallee ()-> getDefiningInstruction ( ));
571
+ getNameFromDecl (mi-> getMember (). getDecl () ));
560
572
return call.getSelfArgument ();
561
573
}
562
-
563
- return SILValue ();
564
574
}
565
575
566
576
return SILValue ();
@@ -655,7 +665,7 @@ StringRef VariableNameInferrer::getNameFromDecl(Decl *d) {
655
665
}
656
666
}
657
667
658
- return " <unknown decl> " ;
668
+ return UnknownDeclString ;
659
669
}
660
670
661
671
void VariableNameInferrer::popSingleVariableName () {
@@ -666,29 +676,7 @@ void VariableNameInferrer::popSingleVariableName() {
666
676
return ;
667
677
}
668
678
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;
692
680
}
693
681
694
682
void VariableNameInferrer::drainVariableNamePath () {
0 commit comments