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