[PATCH] D150449: [NFC] Add reverse iterator support for BasicBlocks in llvm::Function

Tianao Ge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 07:32:30 PDT 2023


getianao created this revision.
getianao added reviewers: vporpo, aeubanks, asbirlea.
Herald added a project: All.
getianao requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In commit D140162 <https://reviews.llvm.org/D140162>, public access to `BasicBlocks` in `llvm::Function` was removed, including access to `getBasicBlockList()`. This revision aims to add reverse iterator support for `BasicBlocks` in `llvm::Function` to make it easier for developers to work with LLVM functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150449

Files:
  llvm/include/llvm/IR/Function.h


Index: llvm/include/llvm/IR/Function.h
===================================================================
--- llvm/include/llvm/IR/Function.h
+++ llvm/include/llvm/IR/Function.h
@@ -64,6 +64,8 @@
   // BasicBlock iterators...
   using iterator = BasicBlockListType::iterator;
   using const_iterator = BasicBlockListType::const_iterator;
+  using reverse_iterator = BasicBlockListType::reverse_iterator;
+  using const_reverse_iterator = BasicBlockListType::const_reverse_iterator;
 
   using arg_iterator = Argument *;
   using const_arg_iterator = const Argument *;
@@ -766,6 +768,10 @@
   const_iterator          begin() const { return BasicBlocks.begin(); }
   iterator                end  ()       { return BasicBlocks.end();   }
   const_iterator          end  () const { return BasicBlocks.end();   }
+  reverse_iterator rbegin() { return BasicBlocks.rbegin(); }
+  const_reverse_iterator rbegin() const { return BasicBlocks.rbegin(); }
+  reverse_iterator rend() { return BasicBlocks.rend(); }
+  const_reverse_iterator rend() const { return BasicBlocks.rend(); }
 
   size_t                   size() const { return BasicBlocks.size();  }
   bool                    empty() const { return BasicBlocks.empty(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150449.521646.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/ee7344e8/attachment.bin>


More information about the llvm-commits mailing list