Skip to content

Commit 2b1327b

Browse files
committed
[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. llvm-svn: 335759
1 parent f472f61 commit 2b1327b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/include/llvm/Object/IRObjectFile.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ class IRObjectFile : public SymbolicFile {
5050
return v->isIR();
5151
}
5252

53+
using module_iterator =
54+
pointee_iterator<std::vector<std::unique_ptr<Module>>::const_iterator,
55+
const Module>;
56+
57+
module_iterator module_begin() const { return module_iterator(Mods.begin()); }
58+
module_iterator module_end() const { return module_iterator(Mods.end()); }
59+
60+
iterator_range<module_iterator> modules() const {
61+
return make_range(module_begin(), module_end());
62+
}
63+
5364
/// Finds and returns bitcode embedded in the given object file, or an
5465
/// error code if not found.
5566
static Expected<MemoryBufferRef> findBitcodeInObject(const ObjectFile &Obj);

0 commit comments

Comments
 (0)