From 05d8dc66df9978331ca702c8535fdfeb7fcb31a2 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 9 Mar 2014 12:20:30 +0000 Subject: [PATCH] [C++11] Add range views for various parts of a Module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203394 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Module.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index f67b5490151..f0d4002000d 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -15,6 +15,7 @@ #ifndef LLVM_IR_MODULE_H #define LLVM_IR_MODULE_H +#include "llvm/ADT/iterator_range.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalAlias.h" @@ -517,6 +518,13 @@ public: const_global_iterator global_end () const { return GlobalList.end(); } bool global_empty() const { return GlobalList.empty(); } + iterator_range globals() { + return iterator_range(global_begin(), global_end()); + } + iterator_range globals() const { + return iterator_range(global_begin(), global_end()); + } + /// @} /// @name Function Iteration /// @{ @@ -539,6 +547,12 @@ public: size_t alias_size () const { return AliasList.size(); } bool alias_empty() const { return AliasList.empty(); } + iterator_range aliases() { + return iterator_range(alias_begin(), alias_end()); + } + iterator_range aliases() const { + return iterator_range(alias_begin(), alias_end()); + } /// @} /// @name Named Metadata Iteration @@ -557,6 +571,14 @@ public: size_t named_metadata_size() const { return NamedMDList.size(); } bool named_metadata_empty() const { return NamedMDList.empty(); } + iterator_range named_metadata() { + return iterator_range(named_metadata_begin(), + named_metadata_end()); + } + iterator_range named_metadata() const { + return iterator_range(named_metadata_begin(), + named_metadata_end()); + } /// @} /// @name Utility functions for printing and dumping Module objects