[PATCH] D30803: [RegionInfo] Don't return an invalid pointer when removing a subregion

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 18:49:06 PST 2017


thegameg updated this revision to Diff 91252.
thegameg added a comment.

Fix typo in comment.


https://reviews.llvm.org/D30803

Files:
  include/llvm/Analysis/RegionInfo.h
  include/llvm/Analysis/RegionInfoImpl.h


Index: include/llvm/Analysis/RegionInfoImpl.h
===================================================================
--- include/llvm/Analysis/RegionInfoImpl.h
+++ include/llvm/Analysis/RegionInfoImpl.h
@@ -398,16 +398,15 @@
 }
 
 template <class Tr>
-typename Tr::RegionT *RegionBase<Tr>::removeSubRegion(RegionT *Child) {
+void RegionBase<Tr>::removeSubRegion(RegionT *Child) {
   assert(Child->parent == this && "Child is not a child of this region!");
   Child->parent = nullptr;
   typename RegionSet::iterator I =
       find_if(children, [&](const std::unique_ptr<RegionT> &R) {
         return R.get() == Child;
       });
   assert(I != children.end() && "Region does not exit. Unable to remove.");
-  children.erase(children.begin() + (I - begin()));
-  return Child;
+  children.erase(I);
 }
 
 template <class Tr>
Index: include/llvm/Analysis/RegionInfo.h
===================================================================
--- include/llvm/Analysis/RegionInfo.h
+++ include/llvm/Analysis/RegionInfo.h
@@ -516,10 +516,9 @@
 
   /// @brief Remove a subregion from this Region.
   ///
-  /// The subregion is not deleted, as it will probably be inserted into another
-  /// region.
-  /// @param SubRegion The SubRegion that will be removed.
-  RegionT *removeSubRegion(RegionT *SubRegion);
+  /// @param SubRegion The SubRegion that will be removed from this region's
+  /// children, and then deleted.
+  void removeSubRegion(RegionT *SubRegion);
 
   /// @brief Move all direct child nodes of this Region to another Region.
   ///


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30803.91252.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170310/afab5e1b/attachment.bin>


More information about the llvm-commits mailing list