@@ -1697,65 +1697,89 @@ bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
1697
1697
return file_path.contains (" /usr/include/c++/" );
1698
1698
}
1699
1699
1700
+ static VariableListSP GetFunctionVariableList (const SymbolContext &sc) {
1701
+ assert (sc.function );
1702
+
1703
+ if (sc.block )
1704
+ if (Block *inline_block = sc.block ->GetContainingInlinedBlock ())
1705
+ return inline_block->GetBlockVariableList (true );
1706
+
1707
+ return sc.function ->GetBlock (true ).GetBlockVariableList (true );
1708
+ }
1709
+
1710
+ static char const *GetInlinedFunctionName (const SymbolContext &sc) {
1711
+ if (!sc.block )
1712
+ return nullptr ;
1713
+
1714
+ const Block *inline_block = sc.block ->GetContainingInlinedBlock ();
1715
+ if (!inline_block)
1716
+ return nullptr ;
1717
+
1718
+ const InlineFunctionInfo *inline_info =
1719
+ inline_block->GetInlinedFunctionInfo ();
1720
+ if (!inline_info)
1721
+ return nullptr ;
1722
+
1723
+ return inline_info->GetName ().AsCString (nullptr );
1724
+ }
1725
+
1726
+ static bool PrintFunctionNameWithArgs (Stream &s,
1727
+ const ExecutionContext *exe_ctx,
1728
+ const SymbolContext &sc) {
1729
+ assert (sc.function );
1730
+
1731
+ ExecutionContextScope *exe_scope =
1732
+ exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1733
+
1734
+ const char *cstr = sc.function ->GetName ().AsCString (nullptr );
1735
+ if (!cstr)
1736
+ return false ;
1737
+
1738
+ if (const char *inlined_name = GetInlinedFunctionName (sc)) {
1739
+ s.PutCString (cstr);
1740
+ s.PutCString (" [inlined] " );
1741
+ cstr = inlined_name;
1742
+ }
1743
+
1744
+ VariableList args;
1745
+ if (auto variable_list_sp = GetFunctionVariableList (sc))
1746
+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1747
+ args);
1748
+
1749
+ if (args.GetSize () > 0 )
1750
+ return PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args);
1751
+
1752
+ // FIXME: can we just unconditionally call PrettyPrintFunctionNameWithArgs?
1753
+ // It should be able to handle the "no arguments" case.
1754
+ s.PutCString (cstr);
1755
+
1756
+ return true ;
1757
+ }
1758
+
1700
1759
bool CPlusPlusLanguage::GetFunctionDisplayName (
1701
1760
const SymbolContext *sc, const ExecutionContext *exe_ctx,
1702
1761
FunctionNameRepresentation representation, Stream &s) {
1703
1762
switch (representation) {
1704
1763
case FunctionNameRepresentation::eNameWithArgs: {
1764
+ assert (sc);
1765
+
1705
1766
// Print the function name with arguments in it
1706
- if (sc->function ) {
1707
- ExecutionContextScope *exe_scope =
1708
- exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1709
- const char *cstr = sc->function ->GetName ().AsCString (nullptr );
1710
- if (cstr) {
1711
- const InlineFunctionInfo *inline_info = nullptr ;
1712
- VariableListSP variable_list_sp;
1713
- bool get_function_vars = true ;
1714
- if (sc->block ) {
1715
- Block *inline_block = sc->block ->GetContainingInlinedBlock ();
1716
-
1717
- if (inline_block) {
1718
- get_function_vars = false ;
1719
- inline_info = inline_block->GetInlinedFunctionInfo ();
1720
- if (inline_info)
1721
- variable_list_sp = inline_block->GetBlockVariableList (true );
1722
- }
1723
- }
1724
-
1725
- if (get_function_vars) {
1726
- variable_list_sp =
1727
- sc->function ->GetBlock (true ).GetBlockVariableList (true );
1728
- }
1729
-
1730
- if (inline_info) {
1731
- s.PutCString (cstr);
1732
- s.PutCString (" [inlined] " );
1733
- cstr = inline_info->GetName ().GetCString ();
1734
- }
1735
-
1736
- VariableList args;
1737
- if (variable_list_sp)
1738
- variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1739
- args);
1740
- if (args.GetSize () > 0 ) {
1741
- if (!PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args))
1742
- return false ;
1743
- } else {
1744
- s.PutCString (cstr);
1745
- }
1746
- return true ;
1747
- }
1748
- } else if (sc->symbol ) {
1749
- const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1750
- if (cstr) {
1751
- s.PutCString (cstr);
1752
- return true ;
1753
- }
1754
- }
1755
- } break ;
1756
- default :
1767
+ if (sc->function )
1768
+ return PrintFunctionNameWithArgs (s, exe_ctx, *sc);
1769
+
1770
+ if (!sc->symbol )
1771
+ return false ;
1772
+
1773
+ const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1774
+ if (!cstr)
1775
+ return false ;
1776
+
1777
+ s.PutCString (cstr);
1778
+
1779
+ return true ;
1780
+ }
1781
+ case FunctionNameRepresentation::eNameWithNoArgs:
1782
+ case FunctionNameRepresentation::eName:
1757
1783
return false ;
1758
1784
}
1759
-
1760
- return false ;
1761
1785
}
0 commit comments