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