[Lldb-commits] [PATCH] D125437: [lldb/API] Add SBCompileUnit::GetIndexForLineEntry method to SB API
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed May 11 18:32:07 PDT 2022
mib updated this revision to Diff 428829.
mib added a comment.
Addressed @jingham comments:
- Use early returns
- Remove `LineEntry::Compare` call since it's already handled by `CompileUnit::FindLineEntry`
- Add docstring
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125437/new/
https://reviews.llvm.org/D125437
Files:
lldb/bindings/interface/SBCompileUnit.i
lldb/include/lldb/API/SBCompileUnit.h
lldb/source/API/SBCompileUnit.cpp
Index: lldb/source/API/SBCompileUnit.cpp
===================================================================
--- lldb/source/API/SBCompileUnit.cpp
+++ lldb/source/API/SBCompileUnit.cpp
@@ -77,6 +77,20 @@
return sb_line_entry;
}
+uint32_t SBCompileUnit::GetIndexForLineEntry(lldb::SBLineEntry &line_entry,
+ bool exact) const {
+ LLDB_INSTRUMENT_VA(this, line_entry, exact);
+
+ if (!m_opaque_ptr || !line_entry.IsValid())
+ return UINT32_MAX;
+
+ LineEntry found_line_entry;
+
+ return m_opaque_ptr->FindLineEntry(0, line_entry.GetLine(),
+ line_entry.GetFileSpec().get(), exact,
+ &line_entry.ref());
+}
+
uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
SBFileSpec *inline_file_spec) const {
LLDB_INSTRUMENT_VA(this, start_idx, line, inline_file_spec);
Index: lldb/include/lldb/API/SBCompileUnit.h
===================================================================
--- lldb/include/lldb/API/SBCompileUnit.h
+++ lldb/include/lldb/API/SBCompileUnit.h
@@ -34,6 +34,9 @@
lldb::SBLineEntry GetLineEntryAtIndex(uint32_t idx) const;
+ uint32_t GetIndexForLineEntry(lldb::SBLineEntry &line_entry,
+ bool exact = false) const;
+
uint32_t FindLineEntryIndex(uint32_t start_idx, uint32_t line,
lldb::SBFileSpec *inline_file_spec) const;
Index: lldb/bindings/interface/SBCompileUnit.i
===================================================================
--- lldb/bindings/interface/SBCompileUnit.i
+++ lldb/bindings/interface/SBCompileUnit.i
@@ -67,6 +67,22 @@
lldb::SBLineEntry
GetLineEntryAtIndex (uint32_t idx) const;
+ %feature("docstring", "
+ Get the index for a provided line entry in this compile unit.
+
+ @param[in] line_entry
+ The SBLineEntry object for which we are looking for the index.
+
+ @param[in] exact
+ An optional boolean defaulting to false that ensures that the provided
+ line entry has a perfect match in the compile unit.
+
+ @return
+ The index of the user-provided line entry. UINT32_MAX if the line entry
+ was not found in the compile unit.") GetIndexForLineEntry;
+ uint32_t
+ GetIndexForLineEntry (lldb::SBLineEntry &line_entry, bool exact = false) const;
+
uint32_t
FindLineEntryIndex (uint32_t start_idx,
uint32_t line,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125437.428829.patch
Type: text/x-patch
Size: 2534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220512/817012b5/attachment-0001.bin>
More information about the lldb-commits
mailing list