[Lldb-commits] [lldb] f9632ce - [lldb] Remove FileSpecList::GetFileSpecPointerAtIndex (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 19 13:13:39 PDT 2023
Author: Jonas Devlieghere
Date: 2023-10-19T13:13:31-07:00
New Revision: f9632cee30b788df7a6241d7802224d8f633973a
URL: https://github.com/llvm/llvm-project/commit/f9632cee30b788df7a6241d7802224d8f633973a
DIFF: https://github.com/llvm/llvm-project/commit/f9632cee30b788df7a6241d7802224d8f633973a.diff
LOG: [lldb] Remove FileSpecList::GetFileSpecPointerAtIndex (NFC)
There's only one use and it eventually converts the pointer into a
reference. Simplify things and always use references.
Added:
Modified:
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Utility/FileSpecList.h
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Target/Target.cpp
lldb/source/Utility/FileSpecList.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 8752b42a9518983..82045988018b606 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -683,7 +683,7 @@ class Target : public std::enable_shared_from_this<Target>,
// Use this to create a breakpoint from a load address and a module file spec
lldb::BreakpointSP CreateAddressInModuleBreakpoint(lldb::addr_t file_addr,
bool internal,
- const FileSpec *file_spec,
+ const FileSpec &file_spec,
bool request_hardware);
// Use this to create Address breakpoints:
diff --git a/lldb/include/lldb/Utility/FileSpecList.h b/lldb/include/lldb/Utility/FileSpecList.h
index 6b88cd2f3091379..14e8069f5ebd6d2 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -155,19 +155,6 @@ class FileSpecList {
/// returned.
const FileSpec &GetFileSpecAtIndex(size_t idx) const;
- /// Get file specification pointer at index.
- ///
- /// Gets a file from the file list. The file objects that are returned can
- /// be tested using FileSpec::operator void*().
- ///
- /// \param[in] idx
- /// An index into the file list.
- ///
- /// \return
- /// A pointer to a contained FileSpec object at index \a idx.
- /// If \a idx is out of range, then an NULL is returned.
- const FileSpec *GetFileSpecPointerAtIndex(size_t idx) const;
-
/// Get the memory cost of this object.
///
/// Return the size in bytes that this object takes in memory. This returns
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 327dae4fd2afbba..18cbb9528b717a5 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -603,8 +603,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
// will track the load location of the library.
size_t num_modules_specified = m_options.m_modules.GetSize();
if (num_modules_specified == 1) {
- const FileSpec *file_spec =
- m_options.m_modules.GetFileSpecPointerAtIndex(0);
+ const FileSpec &file_spec =
+ m_options.m_modules.GetFileSpecAtIndex(0);
bp_sp = target.CreateAddressInModuleBreakpoint(
m_options.m_load_addr, internal, file_spec, m_options.m_hardware);
} else if (num_modules_specified == 0) {
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 069b7bcdc40e614..5f8756c57675c95 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -480,12 +480,12 @@ BreakpointSP Target::CreateBreakpoint(const Address &addr, bool internal,
lldb::BreakpointSP
Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal,
- const FileSpec *file_spec,
+ const FileSpec &file_spec,
bool request_hardware) {
SearchFilterSP filter_sp(
new SearchFilterForUnconstrainedSearches(shared_from_this()));
BreakpointResolverSP resolver_sp(new BreakpointResolverAddress(
- nullptr, file_addr, file_spec ? *file_spec : FileSpec()));
+ nullptr, file_addr, file_spec));
return CreateBreakpoint(filter_sp, resolver_sp, internal, request_hardware,
false);
}
diff --git a/lldb/source/Utility/FileSpecList.cpp b/lldb/source/Utility/FileSpecList.cpp
index e5e0ac3e5981b1b..35486fdc7eff16e 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -140,12 +140,6 @@ const FileSpec &FileSpecList::GetFileSpecAtIndex(size_t idx) const {
return g_empty_file_spec;
}
-const FileSpec *FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const {
- if (idx < m_files.size())
- return &m_files[idx];
- return nullptr;
-}
-
// Return the size in bytes that this object takes in memory. This returns the
// size in bytes of this object's member variables and any FileSpec objects its
// member variables contain, the result doesn't not include the string values
More information about the lldb-commits
mailing list