@@ -1207,7 +1207,8 @@ bool SwiftLanguage::IsSourceFile(llvm::StringRef file_path) const {
1207
1207
return file_path.endswith (" .swift" );
1208
1208
}
1209
1209
1210
- std::vector<FormattersMatchCandidate> SwiftLanguage::GetPossibleFormattersMatches (
1210
+ std::vector<FormattersMatchCandidate>
1211
+ SwiftLanguage::GetPossibleFormattersMatches (
1211
1212
ValueObject &valobj, lldb::DynamicValueType use_dynamic) {
1212
1213
std::vector<FormattersMatchCandidate> result;
1213
1214
@@ -1636,152 +1637,154 @@ bool SwiftLanguage::GetFunctionDisplayName(
1636
1637
SwiftScratchContextLock scratch_ctx_lock (exe_ctx);
1637
1638
switch (representation) {
1638
1639
case Language::FunctionNameRepresentation::eName:
1639
- break ; // no need to customize this
1640
+ // No need to customize this.
1641
+ return false ;
1640
1642
case Language::FunctionNameRepresentation::eNameWithNoArgs: {
1641
- if (sc->function ) {
1642
- if (sc->function ->GetLanguage () == eLanguageTypeSwift) {
1643
- if (ConstString cs = sc->function ->GetDisplayName (sc)) {
1644
- s.Printf (" %s" , cs.AsCString ());
1645
- return true ;
1646
- }
1647
- }
1648
- }
1649
- break ;
1643
+ if (!sc->function )
1644
+ return false ;
1645
+ if (sc->function ->GetLanguage () != eLanguageTypeSwift)
1646
+ return false ;
1647
+ std::string display_name = SwiftLanguageRuntime::DemangleSymbolAsString (
1648
+ sc->function ->GetMangled ().GetMangledName ().GetStringRef (),
1649
+ SwiftLanguageRuntime::eSimplified, sc, exe_ctx);
1650
+ if (display_name.empty ())
1651
+ return false ;
1652
+ s << display_name;
1653
+ return true ;
1650
1654
}
1651
1655
case Language::FunctionNameRepresentation::eNameWithArgs: {
1652
- if (sc->function ) {
1653
- if (sc->function ->GetLanguage () == eLanguageTypeSwift) {
1654
- if (const char *cstr = sc->function ->GetDisplayName (sc).AsCString ()) {
1655
- ExecutionContextScope *exe_scope =
1656
- exe_ctx ? exe_ctx->GetBestExecutionContextScope () : NULL ;
1657
- const InlineFunctionInfo *inline_info = NULL ;
1658
- VariableListSP variable_list_sp;
1659
- bool get_function_vars = true ;
1660
- if (sc->block ) {
1661
- Block *inline_block = sc->block ->GetContainingInlinedBlock ();
1662
-
1663
- if (inline_block) {
1664
- get_function_vars = false ;
1665
- inline_info = sc->block ->GetInlinedFunctionInfo ();
1666
- if (inline_info)
1667
- variable_list_sp = inline_block->GetBlockVariableList (true );
1668
- }
1669
- }
1670
-
1671
- if (get_function_vars) {
1672
- variable_list_sp =
1673
- sc->function ->GetBlock (true ).GetBlockVariableList (true );
1674
- }
1675
-
1676
- if (inline_info) {
1677
- s.PutCString (cstr);
1678
- s.PutCString (" [inlined] " );
1679
- cstr = inline_info->GetName ().GetCString ();
1680
- }
1656
+ if (!sc->function )
1657
+ return false ;
1658
+ if (sc->function ->GetLanguage () != eLanguageTypeSwift)
1659
+ return false ;
1660
+ std::string display_name = SwiftLanguageRuntime::DemangleSymbolAsString (
1661
+ sc->function ->GetMangled ().GetMangledName ().GetStringRef (),
1662
+ SwiftLanguageRuntime::eSimplified, sc, exe_ctx);
1663
+ if (display_name.empty ())
1664
+ return false ;
1665
+ ExecutionContextScope *exe_scope =
1666
+ exe_ctx ? exe_ctx->GetBestExecutionContextScope () : NULL ;
1667
+ const InlineFunctionInfo *inline_info = NULL ;
1668
+ VariableListSP variable_list_sp;
1669
+ bool get_function_vars = true ;
1670
+ if (sc->block ) {
1671
+ Block *inline_block = sc->block ->GetContainingInlinedBlock ();
1672
+
1673
+ if (inline_block) {
1674
+ get_function_vars = false ;
1675
+ inline_info = sc->block ->GetInlinedFunctionInfo ();
1676
+ if (inline_info)
1677
+ variable_list_sp = inline_block->GetBlockVariableList (true );
1678
+ }
1679
+ }
1681
1680
1682
- VariableList args;
1683
- if (variable_list_sp)
1684
- variable_list_sp->AppendVariablesWithScope (
1685
- eValueTypeVariableArgument, args);
1686
- if (args.GetSize () > 0 ) {
1687
- const char *open_paren = strchr (cstr, ' (' );
1688
- const char *close_paren = nullptr ;
1689
- const char *generic = strchr (cstr, ' <' );
1690
- // if before the arguments list begins there is a template sign
1691
- // then scan to the end of the generic args before you try to find
1692
- // the arguments list
1693
- if (generic && open_paren && generic < open_paren) {
1694
- int generic_depth = 1 ;
1695
- ++generic;
1696
- for (; *generic && generic_depth > 0 ; generic++) {
1697
- if (*generic == ' <' )
1698
- generic_depth++;
1699
- if (*generic == ' >' )
1700
- generic_depth--;
1701
- }
1702
- if (*generic)
1703
- open_paren = strchr (generic, ' (' );
1704
- else
1705
- open_paren = nullptr ;
1706
- }
1707
- if (open_paren) {
1708
- close_paren = strchr (open_paren, ' )' );
1709
- }
1681
+ if (get_function_vars) {
1682
+ variable_list_sp =
1683
+ sc->function ->GetBlock (true ).GetBlockVariableList (true );
1684
+ }
1710
1685
1711
- if (open_paren)
1712
- s.Write (cstr, open_paren - cstr + 1 );
1713
- else {
1714
- s.PutCString (cstr);
1715
- s.PutChar (' (' );
1716
- }
1717
- const size_t num_args = args.GetSize ();
1718
- for (size_t arg_idx = 0 ; arg_idx < num_args; ++arg_idx) {
1719
- std::string buffer;
1720
-
1721
- VariableSP var_sp (args.GetVariableAtIndex (arg_idx));
1722
- ValueObjectSP var_value_sp (
1723
- ValueObjectVariable::Create (exe_scope, var_sp));
1724
- StreamString ss;
1725
- const char *var_representation = nullptr ;
1726
- const char *var_name = var_value_sp->GetName ().GetCString ();
1727
- if (var_value_sp->GetCompilerType ().IsValid ()) {
1728
- if (var_value_sp && exe_scope->CalculateTarget ())
1729
- var_value_sp =
1730
- var_value_sp->GetQualifiedRepresentationIfAvailable (
1731
- exe_scope->CalculateTarget ()
1732
- ->TargetProperties ::GetPreferDynamicValue (),
1733
- exe_scope->CalculateTarget ()
1734
- ->TargetProperties ::GetEnableSyntheticValue ());
1735
- if (var_value_sp->GetCompilerType ().IsAggregateType () &&
1736
- DataVisualization::ShouldPrintAsOneLiner (
1737
- *var_value_sp.get ())) {
1738
- static StringSummaryFormat format (
1739
- TypeSummaryImpl::Flags ()
1740
- .SetHideItemNames (false )
1741
- .SetShowMembersOneLiner (true ),
1742
- " " );
1743
- format.FormatObject (var_value_sp.get (), buffer,
1744
- TypeSummaryOptions ());
1745
- var_representation = buffer.c_str ();
1746
- } else
1747
- var_value_sp->DumpPrintableRepresentation (
1748
- ss,
1749
- ValueObject::ValueObjectRepresentationStyle::
1750
- eValueObjectRepresentationStyleSummary,
1751
- eFormatDefault,
1752
- ValueObject::PrintableRepresentationSpecialCases::eAllow,
1753
- false );
1754
- }
1755
- if (ss.GetData () && ss.GetSize ())
1756
- var_representation = ss.GetData ();
1757
- if (arg_idx > 0 )
1758
- s.PutCString (" , " );
1759
- if (var_value_sp->GetError ().Success ()) {
1760
- if (var_representation)
1761
- s.Printf (" %s=%s" , var_name, var_representation);
1762
- else
1763
- s.Printf (" %s=%s at %s" , var_name,
1764
- var_value_sp->GetTypeName ().GetCString (),
1765
- var_value_sp->GetLocationAsCString ());
1766
- } else
1767
- s.Printf (" %s=<unavailable>" , var_name);
1768
- }
1686
+ if (inline_info) {
1687
+ s << display_name;
1688
+ s.PutCString (" [inlined] " );
1689
+ display_name = inline_info->GetName ();
1690
+ }
1769
1691
1770
- if (close_paren)
1771
- s.PutCString (close_paren);
1772
- else
1773
- s.PutChar (' )' );
1692
+ VariableList args;
1693
+ if (variable_list_sp)
1694
+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1695
+ args);
1696
+ if (args.GetSize () == 0 ) {
1697
+ s << display_name;
1698
+ return true ;
1699
+ }
1700
+ const char *cstr = display_name.data ();
1701
+ const char *open_paren = strchr (cstr, ' (' );
1702
+ const char *close_paren = nullptr ;
1703
+ const char *generic = strchr (cstr, ' <' );
1704
+ // If before the arguments list begins there is a template sign
1705
+ // then scan to the end of the generic args before you try to find
1706
+ // the arguments list.
1707
+ if (generic && open_paren && generic < open_paren) {
1708
+ int generic_depth = 1 ;
1709
+ ++generic;
1710
+ for (; *generic && generic_depth > 0 ; generic++) {
1711
+ if (*generic == ' <' )
1712
+ generic_depth++;
1713
+ if (*generic == ' >' )
1714
+ generic_depth--;
1715
+ }
1716
+ if (*generic)
1717
+ open_paren = strchr (generic, ' (' );
1718
+ else
1719
+ open_paren = nullptr ;
1720
+ }
1721
+ if (open_paren) {
1722
+ close_paren = strchr (open_paren, ' )' );
1723
+ }
1774
1724
1775
- } else {
1776
- s.PutCString (cstr);
1777
- }
1778
- return true ;
1779
- }
1725
+ if (open_paren)
1726
+ s.Write (cstr, open_paren - cstr + 1 );
1727
+ else {
1728
+ s << display_name;
1729
+ s.PutChar (' (' );
1730
+ }
1731
+ const size_t num_args = args.GetSize ();
1732
+ for (size_t arg_idx = 0 ; arg_idx < num_args; ++arg_idx) {
1733
+ std::string buffer;
1734
+
1735
+ VariableSP var_sp (args.GetVariableAtIndex (arg_idx));
1736
+ ValueObjectSP var_value_sp (
1737
+ ValueObjectVariable::Create (exe_scope, var_sp));
1738
+ if (!var_sp || !var_value_sp || var_sp->IsArtificial ())
1739
+ continue ;
1740
+ StreamString ss;
1741
+ const char *var_representation = nullptr ;
1742
+ const char *var_name = var_value_sp->GetName ().GetCString ();
1743
+ if (var_value_sp->GetCompilerType ().IsValid ()) {
1744
+ if (var_value_sp && exe_scope->CalculateTarget ())
1745
+ var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable (
1746
+ exe_scope->CalculateTarget ()
1747
+ ->TargetProperties ::GetPreferDynamicValue (),
1748
+ exe_scope->CalculateTarget ()
1749
+ ->TargetProperties ::GetEnableSyntheticValue ());
1750
+ if (var_value_sp->GetCompilerType ().IsAggregateType () &&
1751
+ DataVisualization::ShouldPrintAsOneLiner (*var_value_sp.get ())) {
1752
+ static StringSummaryFormat format (TypeSummaryImpl::Flags ()
1753
+ .SetHideItemNames (false )
1754
+ .SetShowMembersOneLiner (true ),
1755
+ " " );
1756
+ format.FormatObject (var_value_sp.get (), buffer, TypeSummaryOptions ());
1757
+ var_representation = buffer.c_str ();
1758
+ } else
1759
+ var_value_sp->DumpPrintableRepresentation (
1760
+ ss,
1761
+ ValueObject::ValueObjectRepresentationStyle::
1762
+ eValueObjectRepresentationStyleSummary,
1763
+ eFormatDefault,
1764
+ ValueObject::PrintableRepresentationSpecialCases::eAllow, false );
1780
1765
}
1766
+ if (ss.GetData () && ss.GetSize ())
1767
+ var_representation = ss.GetData ();
1768
+ if (arg_idx > 0 )
1769
+ s.PutCString (" , " );
1770
+ if (var_value_sp->GetError ().Success ()) {
1771
+ if (var_representation)
1772
+ s.Printf (" %s=%s" , var_name, var_representation);
1773
+ else
1774
+ s.Printf (" %s=%s at %s" , var_name,
1775
+ var_value_sp->GetTypeName ().GetCString (),
1776
+ var_value_sp->GetLocationAsCString ());
1777
+ } else
1778
+ s.Printf (" %s=<unavailable>" , var_name);
1781
1779
}
1782
- }
1783
- }
1784
1780
1781
+ if (close_paren)
1782
+ s.PutCString (close_paren);
1783
+ else
1784
+ s.PutChar (' )' );
1785
+ }
1786
+ return true ;
1787
+ }
1785
1788
return false ;
1786
1789
}
1787
1790
0 commit comments