@@ -1162,6 +1162,64 @@ static void FormatInlinedBlock(Stream &out_stream, Block *block) {
11621162 }
11631163}
11641164
1165+ static VariableListSP GetFunctionVariableList (const SymbolContext &sc) {
1166+ assert (sc.function );
1167+
1168+ if (sc.block )
1169+ if (Block *inline_block = sc.block ->GetContainingInlinedBlock ())
1170+ return inline_block->GetBlockVariableList (true );
1171+
1172+ return sc.function ->GetBlock (true ).GetBlockVariableList (true );
1173+ }
1174+
1175+ static char const *GetInlinedFunctionName (const SymbolContext &sc) {
1176+ if (!sc.block )
1177+ return nullptr ;
1178+
1179+ const Block *inline_block = sc.block ->GetContainingInlinedBlock ();
1180+ if (!inline_block)
1181+ return nullptr ;
1182+
1183+ const InlineFunctionInfo *inline_info =
1184+ inline_block->GetInlinedFunctionInfo ();
1185+ if (!inline_info)
1186+ return nullptr ;
1187+
1188+ return inline_info->GetName ().AsCString (nullptr );
1189+ }
1190+
1191+ static bool PrintFunctionNameWithArgs (Stream &s,
1192+ const ExecutionContext *exe_ctx,
1193+ const SymbolContext &sc) {
1194+ assert (sc.function );
1195+
1196+ ExecutionContextScope *exe_scope =
1197+ exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1198+
1199+ const char *cstr = sc.function ->GetName ().AsCString (nullptr );
1200+ if (!cstr)
1201+ return false ;
1202+
1203+ if (const char *inlined_name = GetInlinedFunctionName (sc)) {
1204+ s.PutCString (cstr);
1205+ s.PutCString (" [inlined] " );
1206+ cstr = inlined_name;
1207+ }
1208+
1209+ VariableList args;
1210+ if (auto variable_list_sp = GetFunctionVariableList (sc))
1211+ variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument,
1212+ args);
1213+
1214+ if (args.GetSize () > 0 ) {
1215+ PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args);
1216+ } else {
1217+ s.PutCString (cstr);
1218+ }
1219+
1220+ return true ;
1221+ }
1222+
11651223bool FormatEntity::FormatStringRef (const llvm::StringRef &format_str, Stream &s,
11661224 const SymbolContext *sc,
11671225 const ExecutionContext *exe_ctx,
@@ -1746,59 +1804,21 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
17461804 if (language_plugin_handled) {
17471805 s << ss.GetString ();
17481806 return true ;
1749- } else {
1750- // Print the function name with arguments in it
1751- if (sc->function ) {
1752- ExecutionContextScope *exe_scope =
1753- exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr ;
1754- const char *cstr = sc->function ->GetName ().AsCString (nullptr );
1755- if (cstr) {
1756- const InlineFunctionInfo *inline_info = nullptr ;
1757- VariableListSP variable_list_sp;
1758- bool get_function_vars = true ;
1759- if (sc->block ) {
1760- Block *inline_block = sc->block ->GetContainingInlinedBlock ();
1761-
1762- if (inline_block) {
1763- get_function_vars = false ;
1764- inline_info = inline_block->GetInlinedFunctionInfo ();
1765- if (inline_info)
1766- variable_list_sp = inline_block->GetBlockVariableList (true );
1767- }
1768- }
1807+ }
17691808
1770- if (get_function_vars) {
1771- variable_list_sp =
1772- sc->function ->GetBlock (true ).GetBlockVariableList (true );
1773- }
1809+ if (sc->function )
1810+ return PrintFunctionNameWithArgs (s, exe_ctx, *sc);
17741811
1775- if (inline_info) {
1776- s.PutCString (cstr);
1777- s.PutCString (" [inlined] " );
1778- cstr = inline_info->GetName ().GetCString ();
1779- }
1812+ if (!sc->symbol )
1813+ return false ;
17801814
1781- VariableList args;
1782- if (variable_list_sp)
1783- variable_list_sp->AppendVariablesWithScope (
1784- eValueTypeVariableArgument, args);
1785- if (args.GetSize () > 0 ) {
1786- PrettyPrintFunctionNameWithArgs (s, cstr, exe_scope, args);
1787- } else {
1788- s.PutCString (cstr);
1789- }
1790- return true ;
1791- }
1792- } else if (sc->symbol ) {
1793- const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1794- if (cstr) {
1795- s.PutCString (cstr);
1796- return true ;
1797- }
1798- }
1799- }
1815+ const char *cstr = sc->symbol ->GetName ().AsCString (nullptr );
1816+ if (!cstr)
1817+ return false ;
1818+
1819+ s.PutCString (cstr);
1820+ return true ;
18001821 }
1801- return false ;
18021822
18031823 case Entry::Type::FunctionMangledName: {
18041824 if (!sc)
0 commit comments