[Lldb-commits] [lldb] 52e45a7 - [lldb][Language] Change GetFunctionDisplayName to take SymbolContext by reference (#135536)
via lldb-commits
lldb-commits at lists.llvm.org
Sun Apr 13 15:19:30 PDT 2025
Author: Michael Buch
Date: 2025-04-13T23:19:26+01:00
New Revision: 52e45a79ad24f8a2347a5566e6abaa207918df62
URL: https://github.com/llvm/llvm-project/commit/52e45a79ad24f8a2347a5566e6abaa207918df62
DIFF: https://github.com/llvm/llvm-project/commit/52e45a79ad24f8a2347a5566e6abaa207918df62.diff
LOG: [lldb][Language] Change GetFunctionDisplayName to take SymbolContext by reference (#135536)
Both the `CPlusPlusLanguage` plugins and the Swift language plugin
already assume the `sc != nullptr`. And all `FormatEntity` callsites of
`GetFunctionDisplayName` already check for nullptr before passing `sc`.
This patch makes this pre-condition explicit by changing the parameter
to `const SymbolContext &`. This will help with some upcoming changes in
this area.
Added:
Modified:
lldb/include/lldb/Target/Language.h
lldb/source/Core/FormatEntity.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Target/Language.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h
index b699a90aff8e4..da2c2cc451dae 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -268,7 +268,7 @@ class Language : public PluginInterface {
// the reference has never been assigned
virtual bool IsUninitializedReference(ValueObject &valobj);
- virtual bool GetFunctionDisplayName(const SymbolContext *sc,
+ virtual bool GetFunctionDisplayName(const SymbolContext &sc,
const ExecutionContext *exe_ctx,
FunctionNameRepresentation representation,
Stream &s);
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index a9370595c11e7..7130248100c6f 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1719,7 +1719,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (language_plugin)
language_plugin_handled = language_plugin->GetFunctionDisplayName(
- sc, exe_ctx, Language::FunctionNameRepresentation::eName, ss);
+ *sc, exe_ctx, Language::FunctionNameRepresentation::eName, ss);
if (language_plugin_handled) {
s << ss.GetString();
@@ -1754,7 +1754,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (language_plugin)
language_plugin_handled = language_plugin->GetFunctionDisplayName(
- sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithNoArgs,
+ *sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithNoArgs,
ss);
if (language_plugin_handled) {
@@ -1789,7 +1789,8 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (language_plugin)
language_plugin_handled = language_plugin->GetFunctionDisplayName(
- sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs, ss);
+ *sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs,
+ ss);
if (language_plugin_handled) {
s << ss.GetString();
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index a6fdf66f13e4d..8c05f092dec71 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1757,20 +1757,18 @@ static bool PrintFunctionNameWithArgs(Stream &s,
}
bool CPlusPlusLanguage::GetFunctionDisplayName(
- const SymbolContext *sc, const ExecutionContext *exe_ctx,
+ const SymbolContext &sc, const ExecutionContext *exe_ctx,
FunctionNameRepresentation representation, Stream &s) {
switch (representation) {
case FunctionNameRepresentation::eNameWithArgs: {
- assert(sc);
-
// Print the function name with arguments in it
- if (sc->function)
- return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
+ if (sc.function)
+ return PrintFunctionNameWithArgs(s, exe_ctx, sc);
- if (!sc->symbol)
+ if (!sc.symbol)
return false;
- const char *cstr = sc->symbol->GetName().AsCString(nullptr);
+ const char *cstr = sc.symbol->GetName().AsCString(nullptr);
if (!cstr)
return false;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 623d481bf117f..54f5a94388b92 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -138,7 +138,7 @@ class CPlusPlusLanguage : public Language {
ConstString
GetDemangledFunctionNameWithoutArguments(Mangled mangled) const override;
- bool GetFunctionDisplayName(const SymbolContext *sc,
+ bool GetFunctionDisplayName(const SymbolContext &sc,
const ExecutionContext *exe_ctx,
FunctionNameRepresentation representation,
Stream &s) override;
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index a75894ffa4b3b..86754c251cd93 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -510,7 +510,7 @@ bool Language::IsNilReference(ValueObject &valobj) { return false; }
bool Language::IsUninitializedReference(ValueObject &valobj) { return false; }
-bool Language::GetFunctionDisplayName(const SymbolContext *sc,
+bool Language::GetFunctionDisplayName(const SymbolContext &sc,
const ExecutionContext *exe_ctx,
FunctionNameRepresentation representation,
Stream &s) {
More information about the lldb-commits
mailing list