diff options
author | Alex Langford <alangford@apple.com> | 2023-05-04 13:26:58 -0700 |
---|---|---|
committer | Alex Langford <alangford@apple.com> | 2023-05-04 16:36:44 -0700 |
commit | 04aa943be8ed5c03092e2a90112ac638360ec253 (patch) | |
tree | 45c211c4b200c275522d16e07890e7fc1a05e8ea /lldb/include | |
parent | 4c9c1a4e4f854b2a4891813b2b1d7e1079a52a62 (diff) | |
download | llvm-04aa943be8ed5c03092e2a90112ac638360ec253.tar.gz |
[lldb] Expose a const iterator for SymbolContextList
There are many situations where we'll iterate over a SymbolContextList
with the pattern:
```
SymbolContextList sc_list;
// Fill in sc_list here
for (auto i = 0; i < sc_list.GetSize(); i++) {
SymbolContext sc;
sc_list.GetSymbolAtContext(i, sc);
// Do work with sc
}
```
Adding an iterator to iterate over the instances directly means we don't
have to do bounds checking or create a copy of every element of the
SymbolContextList.
Differential Revision: https://reviews.llvm.org/D149900
Diffstat (limited to 'lldb/include')
-rw-r--r-- | lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/SymbolContext.h | 4 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/UnwindTable.h | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 5864a284d6f1..3747e6d2d9a2 100644 --- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -59,7 +59,7 @@ public: protected: void FilterContexts(SymbolContextList &sc_list); - void DeduceSourceMapping(SymbolContextList &sc_list); + void DeduceSourceMapping(const SymbolContextList &sc_list); friend class Breakpoint; SourceLocationSpec m_location_spec; diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 73fa25514aff..68bef70f3bcf 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -451,11 +451,15 @@ public: protected: typedef std::vector<SymbolContext> collection; ///< The collection type for the list. + typedef collection::const_iterator const_iterator; // Member variables. collection m_symbol_contexts; ///< The list of symbol contexts. public: + const_iterator begin() const { return m_symbol_contexts.begin(); } + const_iterator end() const { return m_symbol_contexts.end(); } + typedef AdaptedIterable<collection, SymbolContext, vector_adapter> SymbolContextIterable; SymbolContextIterable SymbolContexts() { diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h index a3026504dbdf..f0ce7047de2d 100644 --- a/lldb/include/lldb/Symbol/UnwindTable.h +++ b/lldb/include/lldb/Symbol/UnwindTable.h @@ -53,7 +53,7 @@ public: // problem. lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, - SymbolContext &sc); + const SymbolContext &sc); ArchSpec GetArchitecture(); @@ -62,7 +62,7 @@ private: void Initialize(); std::optional<AddressRange> GetAddressRange(const Address &addr, - SymbolContext &sc); + const SymbolContext &sc); typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection; typedef collection::iterator iterator; |