Skip to content

Commit 1a2f2d5

Browse files
committed
[lldb][Format][NFC] Factor FunctionNameWithArgs case out into helper function
(cherry picked from commit af7a7ba)
1 parent 34bc8be commit 1a2f2d5

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

lldb/source/Core/FormatEntity.cpp

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,40 @@ static bool PrintFunctionNameWithArgs(Stream &s,
11861186
return true;
11871187
}
11881188

1189+
static bool HandleFunctionNameWithArgs(Stream &s,const ExecutionContext *exe_ctx,
1190+
const SymbolContext &sc) {
1191+
Language *language_plugin = nullptr;
1192+
bool language_plugin_handled = false;
1193+
StreamString ss;
1194+
if (sc.function)
1195+
language_plugin = Language::FindPlugin(sc.function->GetLanguage());
1196+
else if (sc.symbol)
1197+
language_plugin = Language::FindPlugin(sc.symbol->GetLanguage());
1198+
1199+
if (language_plugin)
1200+
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1201+
sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs, ss);
1202+
1203+
if (language_plugin_handled) {
1204+
s << ss.GetString();
1205+
return true;
1206+
}
1207+
1208+
if (sc.function)
1209+
return PrintFunctionNameWithArgs(s, exe_ctx, sc);
1210+
1211+
if (!sc.symbol)
1212+
return false;
1213+
1214+
const char *cstr = sc.symbol->GetName().AsCString(nullptr);
1215+
if (!cstr)
1216+
return false;
1217+
1218+
s.PutCString(cstr);
1219+
1220+
return true;
1221+
}
1222+
11891223
bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s,
11901224
const SymbolContext *sc,
11911225
const ExecutionContext *exe_ctx,
@@ -1748,36 +1782,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
17481782
if (!sc)
17491783
return false;
17501784

1751-
Language *language_plugin = nullptr;
1752-
bool language_plugin_handled = false;
1753-
StreamString ss;
1754-
if (sc->function)
1755-
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1756-
else if (sc->symbol)
1757-
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1758-
1759-
if (language_plugin)
1760-
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1761-
*sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs,
1762-
ss);
1763-
1764-
if (language_plugin_handled) {
1765-
s << ss.GetString();
1766-
return true;
1767-
}
1768-
1769-
if (sc->function)
1770-
return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
1771-
1772-
if (!sc->symbol)
1773-
return false;
1774-
1775-
const char *cstr = sc->symbol->GetName().AsCString(nullptr);
1776-
if (!cstr)
1777-
return false;
1778-
1779-
s.PutCString(cstr);
1780-
return true;
1785+
return HandleFunctionNameWithArgs(s, exe_ctx, *sc);
17811786
}
17821787

17831788
case Entry::Type::FunctionMangledName: {

0 commit comments

Comments
 (0)