Skip to content

Commit af7a7ba

Browse files
committed
[lldb][Format][NFC] Factor FunctionNameWithArgs case out into helper function
1 parent 634f9a9 commit af7a7ba

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
@@ -1184,6 +1184,40 @@ static bool PrintFunctionNameWithArgs(Stream &s,
11841184
return true;
11851185
}
11861186

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

1741-
Language *language_plugin = nullptr;
1742-
bool language_plugin_handled = false;
1743-
StreamString ss;
1744-
if (sc->function)
1745-
language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1746-
else if (sc->symbol)
1747-
language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1748-
1749-
if (language_plugin)
1750-
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1751-
*sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs,
1752-
ss);
1753-
1754-
if (language_plugin_handled) {
1755-
s << ss.GetString();
1756-
return true;
1757-
}
1758-
1759-
if (sc->function)
1760-
return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
1761-
1762-
if (!sc->symbol)
1763-
return false;
1764-
1765-
const char *cstr = sc->symbol->GetName().AsCString(nullptr);
1766-
if (!cstr)
1767-
return false;
1768-
1769-
s.PutCString(cstr);
1770-
return true;
1775+
return HandleFunctionNameWithArgs(s, exe_ctx, *sc);
17711776
}
17721777

17731778
case Entry::Type::FunctionMangledName: {

0 commit comments

Comments
 (0)