summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBFunction.cpp
diff options
context:
space:
mode:
authorAlex Langford <alangford@apple.com>2023-05-17 10:44:38 -0700
committerAlex Langford <alangford@apple.com>2023-05-18 15:13:36 -0700
commit41714c959d65ff1dd842bc0a0d44f90b06440c39 (patch)
treeb3a07e61238e2ab7ec0679a870fb6578bb0ba0a3 /lldb/source/API/SBFunction.cpp
parent6abd8e30f443b9b17935c40e4451cbc63e3bd49d (diff)
[lldb] Guarantee the lifetimes of all strings returned from SBAPI
LLDB should guarantee that the strings returned by SBAPI methods live forever. I went through every method that returns a string and made sure that it was added to the ConstString StringPool before returning if it wasn't obvious that it was already doing so. I've also updated the docs to document this behavior. Differential Revision: https://reviews.llvm.org/D150804
Diffstat (limited to 'lldb/source/API/SBFunction.cpp')
-rw-r--r--lldb/source/API/SBFunction.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 562cae4e8906..a01c7f79bbd3 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -54,30 +54,27 @@ SBFunction::operator bool() const {
const char *SBFunction::GetName() const {
LLDB_INSTRUMENT_VA(this);
- const char *cstr = nullptr;
if (m_opaque_ptr)
- cstr = m_opaque_ptr->GetName().AsCString();
+ return m_opaque_ptr->GetName().AsCString();
- return cstr;
+ return nullptr;
}
const char *SBFunction::GetDisplayName() const {
LLDB_INSTRUMENT_VA(this);
- const char *cstr = nullptr;
if (m_opaque_ptr)
- cstr = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
+ return m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
- return cstr;
+ return nullptr;
}
const char *SBFunction::GetMangledName() const {
LLDB_INSTRUMENT_VA(this);
- const char *cstr = nullptr;
if (m_opaque_ptr)
- cstr = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
- return cstr;
+ return m_opaque_ptr->GetMangled().GetMangledName().AsCString();
+ return nullptr;
}
bool SBFunction::operator==(const SBFunction &rhs) const {
@@ -166,19 +163,22 @@ SBAddress SBFunction::GetEndAddress() {
const char *SBFunction::GetArgumentName(uint32_t arg_idx) {
LLDB_INSTRUMENT_VA(this, arg_idx);
- if (m_opaque_ptr) {
- Block &block = m_opaque_ptr->GetBlock(true);
- VariableListSP variable_list_sp = block.GetBlockVariableList(true);
- if (variable_list_sp) {
- VariableList arguments;
- variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,
- arguments, true);
- lldb::VariableSP variable_sp = arguments.GetVariableAtIndex(arg_idx);
- if (variable_sp)
- return variable_sp->GetName().GetCString();
- }
- }
- return nullptr;
+ if (!m_opaque_ptr)
+ return nullptr;
+
+ Block &block = m_opaque_ptr->GetBlock(true);
+ VariableListSP variable_list_sp = block.GetBlockVariableList(true);
+ if (!variable_list_sp)
+ return nullptr;
+
+ VariableList arguments;
+ variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument,
+ arguments, true);
+ lldb::VariableSP variable_sp = arguments.GetVariableAtIndex(arg_idx);
+ if (!variable_sp)
+ return nullptr;
+
+ return variable_sp->GetName().GetCString();
}
uint32_t SBFunction::GetPrologueByteSize() {