@@ -507,23 +507,24 @@ SILValue VariableNameInferrer::findDebugInfoProvidingValueHelper(
507
507
508
508
if (auto *dti = dyn_cast_or_null<DestructureTupleInst>(
509
509
searchValue->getDefiningInstruction ())) {
510
- // Append searchValue, so we can find the specific tuple index.
511
- variableNamePath. push_back ( searchValue);
510
+ variableNamePath. push_back (
511
+ getStringRefForIndex (*dti-> getIndexOfResult ( searchValue)) );
512
512
searchValue = dti->getOperand ();
513
513
continue ;
514
514
}
515
515
516
516
if (auto *dsi = dyn_cast_or_null<DestructureStructInst>(
517
517
searchValue->getDefiningInstruction ())) {
518
- // Append searchValue, so we can find the specific struct field.
519
- variableNamePath.push_back (searchValue);
518
+ unsigned index = *dsi->getIndexOfResult (searchValue);
519
+ variableNamePath.push_back (
520
+ getNameFromDecl (dsi->getStructDecl ()->getStoredProperties ()[index]));
520
521
searchValue = dsi->getOperand ();
521
522
continue ;
522
523
}
523
524
524
525
if (auto *fArg = dyn_cast<SILFunctionArgument>(searchValue)) {
525
- if (fArg ->getDecl ()) {
526
- variableNamePath.push_back ({ fArg } );
526
+ if (auto *decl = fArg ->getDecl ()) {
527
+ variableNamePath.push_back (decl-> getBaseName (). userFacingName () );
527
528
return fArg ;
528
529
}
529
530
}
@@ -687,29 +688,6 @@ void VariableNameInferrer::popSingleVariableName() {
687
688
return ;
688
689
}
689
690
690
- if (std::holds_alternative<SILValue>(next)) {
691
- auto value = std::get<SILValue>(next);
692
- if (auto *fArg = dyn_cast<SILFunctionArgument>(value)) {
693
- resultingString += fArg ->getDecl ()->getBaseName ().userFacingName ();
694
- return ;
695
- }
696
-
697
- if (auto *dti = dyn_cast_or_null<DestructureTupleInst>(
698
- value->getDefiningInstruction ())) {
699
- llvm::raw_svector_ostream stream (resultingString);
700
- stream << *dti->getIndexOfResult (value);
701
- return ;
702
- }
703
-
704
- if (auto *dsi = dyn_cast_or_null<DestructureStructInst>(
705
- value->getDefiningInstruction ())) {
706
- unsigned index = *dsi->getIndexOfResult (value);
707
- resultingString +=
708
- getNameFromDecl (dsi->getStructDecl ()->getStoredProperties ()[index]);
709
- return ;
710
- }
711
- }
712
-
713
691
resultingString += " <unknown decl>" ;
714
692
}
715
693
0 commit comments