summaryrefslogtreecommitdiffstats
path: root/lldb/include
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2018-08-11 23:40:27 +0000
committerRaphael Isemann <teemperor@gmail.com>2018-08-11 23:40:27 +0000
commita7f19e5fda36ac148528c43ecb1b7d15803e4196 (patch)
treeaa9d56920d0bc2a10fb26d33c1d695b5222810b1 /lldb/include
parent9b60b9289c2ba9e57a61a98c6dea9aaeb769d850 (diff)
downloadbcm5719-llvm-a7f19e5fda36ac148528c43ecb1b7d15803e4196.tar.gz
bcm5719-llvm-a7f19e5fda36ac148528c43ecb1b7d15803e4196.zip
Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID
Summary: Instead of iterating over our vector of functions, we might as well use a map here to directly get the function we need. Thanks to Vedant for pointing this out. Reviewers: vsk Reviewed By: vsk Subscribers: mgrang, lldb-commits Differential Revision: https://reviews.llvm.org/D50225 llvm-svn: 339504
Diffstat (limited to 'lldb/include')
-rw-r--r--lldb/include/lldb/Symbol/CompileUnit.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h
index b816439cee1..0c9ae2f9989 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -18,6 +18,8 @@
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/DenseMap.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
/// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
@@ -163,21 +165,19 @@ public:
void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
//------------------------------------------------------------------
- /// Get a shared pointer to a function in this compile unit by index.
+ /// Apply a lambda to each function in this compile unit.
///
- /// Typically called when iterating though all functions in a compile unit
- /// after all functions have been parsed. This provides raw access to the
- /// function shared pointer list and will not cause the SymbolFile plug-in
- /// to parse any unparsed functions.
+ /// This provides raw access to the function shared pointer list and will not
+ /// cause the SymbolFile plug-in to parse any unparsed functions.
///
- /// @param[in] idx
- /// An index into the function list.
+ /// @note Prefer using FindFunctionByUID over this if possible.
///
- /// @return
- /// A shared pointer to a function that might contain a NULL
- /// Function class pointer.
+ /// @param[in] lambda
+ /// The lambda that should be applied to every function. The lambda can
+ /// return true if the iteration should be aborted earlier.
//------------------------------------------------------------------
- lldb::FunctionSP GetFunctionAtIndex(size_t idx);
+ void ForeachFunction(
+ llvm::function_ref<bool(const lldb::FunctionSP &)> lambda) const;
//------------------------------------------------------------------
/// Dump the compile unit contents to the stream \a s.
@@ -415,9 +415,9 @@ protected:
lldb::LanguageType
m_language; ///< The programming language enumeration value.
Flags m_flags; ///< Compile unit flags that help with partial parsing.
- std::vector<lldb::FunctionSP> m_functions; ///< The sparsely populated list of
- ///shared pointers to functions
- ///< that gets populated as functions get partially parsed.
+
+ /// Maps UIDs to functions.
+ llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions_by_uid;
std::vector<ConstString> m_imported_modules; ///< All modules, including the
///current module, imported by
///this
OpenPOWER on IntegriCloud