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. /// Index: include/llvm/Analysis/RegionInfoImpl.h =================================================================== --- include/llvm/Analysis/RegionInfoImpl.h +++ include/llvm/Analysis/RegionInfoImpl.h @@ -398,7 +398,7 @@ } template -typename Tr::RegionT *RegionBase::removeSubRegion(RegionT *Child) { +void RegionBase::removeSubRegion(RegionT *Child) { assert(Child->parent == this && "Child is not a child of this region!"); Child->parent = nullptr; typename RegionSet::iterator I = @@ -406,8 +406,7 @@ 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