From f602599e6b360c49f8e9422f2c2d707e1ac1509f Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Wed, 27 Jun 2018 17:58:32 +0000 Subject: [PATCH] [Object] Allow iterating over an IRObjectFile's modules If you've already loaded an IRObjectFile and need access to the Modules themselves you shouldn't have to reparse a byte stream to do it. Adds an accessor for the modules in IRObjectFile. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335759 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/IRObjectFile.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/llvm/Object/IRObjectFile.h b/include/llvm/Object/IRObjectFile.h index 559a91af94d..993359b766a 100644 --- a/include/llvm/Object/IRObjectFile.h +++ b/include/llvm/Object/IRObjectFile.h @@ -50,6 +50,17 @@ public: return v->isIR(); } + using module_iterator = + pointee_iterator>::const_iterator, + const Module>; + + module_iterator module_begin() const { return module_iterator(Mods.begin()); } + module_iterator module_end() const { return module_iterator(Mods.end()); } + + iterator_range modules() const { + return make_range(module_begin(), module_end()); + } + /// Finds and returns bitcode embedded in the given object file, or an /// error code if not found. static Expected findBitcodeInObject(const ObjectFile &Obj); -- 2.11.0