Skip to content

Commit a719c49

Browse files
committed
[lldb][Language] Change GetFunctionDisplayName to take SymbolContext by reference (llvm#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. (cherry picked from commit 52e45a7)
1 parent e16cdd3 commit a719c49

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

lldb/include/lldb/Target/Language.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class Language : public PluginInterface {
270270
// the reference has never been assigned
271271
virtual bool IsUninitializedReference(ValueObject &valobj);
272272

273-
virtual bool GetFunctionDisplayName(const SymbolContext *sc,
273+
virtual bool GetFunctionDisplayName(const SymbolContext &sc,
274274
const ExecutionContext *exe_ctx,
275275
FunctionNameRepresentation representation,
276276
Stream &s);

lldb/source/Core/FormatEntity.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
17291729

17301730
if (language_plugin)
17311731
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1732-
sc, exe_ctx, Language::FunctionNameRepresentation::eName, ss);
1732+
*sc, exe_ctx, Language::FunctionNameRepresentation::eName, ss);
17331733

17341734
if (language_plugin_handled) {
17351735
s << ss.GetString();
@@ -1764,7 +1764,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
17641764

17651765
if (language_plugin)
17661766
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1767-
sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithNoArgs,
1767+
*sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithNoArgs,
17681768
ss);
17691769

17701770
if (language_plugin_handled) {
@@ -1799,7 +1799,8 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
17991799

18001800
if (language_plugin)
18011801
language_plugin_handled = language_plugin->GetFunctionDisplayName(
1802-
sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs, ss);
1802+
*sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs,
1803+
ss);
18031804

18041805
if (language_plugin_handled) {
18051806
s << ss.GetString();

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -1759,20 +1759,18 @@ static bool PrintFunctionNameWithArgs(Stream &s,
17591759
}
17601760

17611761
bool CPlusPlusLanguage::GetFunctionDisplayName(
1762-
const SymbolContext *sc, const ExecutionContext *exe_ctx,
1762+
const SymbolContext &sc, const ExecutionContext *exe_ctx,
17631763
FunctionNameRepresentation representation, Stream &s) {
17641764
switch (representation) {
17651765
case FunctionNameRepresentation::eNameWithArgs: {
1766-
assert(sc);
1767-
17681766
// Print the function name with arguments in it
1769-
if (sc->function)
1770-
return PrintFunctionNameWithArgs(s, exe_ctx, *sc);
1767+
if (sc.function)
1768+
return PrintFunctionNameWithArgs(s, exe_ctx, sc);
17711769

1772-
if (!sc->symbol)
1770+
if (!sc.symbol)
17731771
return false;
17741772

1775-
const char *cstr = sc->symbol->GetName().AsCString(nullptr);
1773+
const char *cstr = sc.symbol->GetName().AsCString(nullptr);
17761774
if (!cstr)
17771775
return false;
17781776

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class CPlusPlusLanguage : public Language {
138138
ConstString
139139
GetDemangledFunctionNameWithoutArguments(Mangled mangled) const override;
140140

141-
bool GetFunctionDisplayName(const SymbolContext *sc,
141+
bool GetFunctionDisplayName(const SymbolContext &sc,
142142
const ExecutionContext *exe_ctx,
143143
FunctionNameRepresentation representation,
144144
Stream &s) override;

lldb/source/Target/Language.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ bool Language::IsNilReference(ValueObject &valobj) { return false; }
510510

511511
bool Language::IsUninitializedReference(ValueObject &valobj) { return false; }
512512

513-
bool Language::GetFunctionDisplayName(const SymbolContext *sc,
513+
bool Language::GetFunctionDisplayName(const SymbolContext &sc,
514514
const ExecutionContext *exe_ctx,
515515
FunctionNameRepresentation representation,
516516
Stream &s) {

0 commit comments

Comments
 (0)