@@ -62,9 +62,9 @@ utl::Logger* Shape::getLogger() const
6262 return grid_component_->getLogger ();
6363}
6464
65- Shape* Shape::copy () const
65+ std::unique_ptr< Shape> Shape::copy () const
6666{
67- auto * shape = new Shape (layer_, net_, rect_, type_);
67+ auto shape = std::make_unique< Shape> (layer_, net_, rect_, type_);
6868 shape->shape_type_ = shape_type_;
6969 shape->obs_ = obs_;
7070 shape->iterm_connections_ = iterm_connections_;
@@ -204,7 +204,7 @@ odb::Rect Shape::getMinimumRect() const
204204
205205bool Shape::cut (const ObstructionTree& obstructions,
206206 const Grid* ignore_grid,
207- std::vector<Shape* >& replacements) const
207+ std::vector<std::unique_ptr< Shape> >& replacements) const
208208{
209209 return cut (
210210 obstructions, replacements, [ignore_grid](const ShapePtr& other) -> bool {
@@ -217,7 +217,7 @@ bool Shape::cut(const ObstructionTree& obstructions,
217217}
218218
219219bool Shape::cut (const ObstructionTree& obstructions,
220- std::vector<Shape* >& replacements,
220+ std::vector<std::unique_ptr< Shape> >& replacements,
221221 const std::function<bool (const ShapePtr&)>& obs_filter) const
222222{
223223 using namespace boost ::polygon::operators;
@@ -306,11 +306,11 @@ bool Shape::cut(const ObstructionTree& obstructions,
306306 }
307307
308308 if (accept) {
309- auto * new_shape = copy ();
309+ auto new_shape = copy ();
310310 new_shape->setRect (new_rect);
311311 new_shape->updateTermConnections ();
312312
313- replacements.push_back (new_shape);
313+ replacements.push_back (std::move ( new_shape) );
314314 }
315315 }
316316 return true ;
@@ -593,12 +593,12 @@ std::string Shape::getRectText(const odb::Rect& rect, double dbu_to_micron)
593593 rect.yMax () / dbu_to_micron);
594594}
595595
596- Shape* Shape::extendTo (
596+ std::unique_ptr< Shape> Shape::extendTo (
597597 const odb::Rect& rect,
598598 const ObstructionTree& obstructions,
599599 const std::function<bool (const ShapePtr&)>& obs_filter) const
600600{
601- std::unique_ptr<Shape> new_shape ( copy () );
601+ std::unique_ptr<Shape> new_shape = copy ();
602602
603603 if (isHorizontal ()) {
604604 new_shape->rect_ .set_xlo (std::min (rect_.xMin (), rect.xMin ()));
@@ -626,7 +626,7 @@ Shape* Shape::extendTo(
626626 return nullptr ;
627627 }
628628
629- return new_shape. release () ;
629+ return new_shape;
630630}
631631
632632Shape::ShapeTreeMap Shape::convertVectorToTree (ShapeVectorMap& vec)
@@ -672,9 +672,10 @@ FollowPinShape::FollowPinShape(odb::dbTechLayer* layer,
672672{
673673}
674674
675- Shape* FollowPinShape::copy () const
675+ std::unique_ptr< Shape> FollowPinShape::copy () const
676676{
677- auto * shape = new FollowPinShape (getLayer (), getNet (), getRect ());
677+ auto shape
678+ = std::make_unique<FollowPinShape>(getLayer (), getNet (), getRect ());
678679 shape->generateObstruction ();
679680 shape->rows_ = rows_;
680681 return shape;
@@ -741,9 +742,10 @@ odb::Rect FollowPinShape::getMinimumRect() const
741742 return min_shape;
742743}
743744
744- bool FollowPinShape::cut (const ObstructionTree& obstructions,
745- const Grid* ignore_grid,
746- std::vector<Shape*>& replacements) const
745+ bool FollowPinShape::cut (
746+ const ObstructionTree& obstructions,
747+ const Grid* ignore_grid,
748+ std::vector<std::unique_ptr<Shape>>& replacements) const
747749{
748750 return Shape::cut (
749751 obstructions, replacements, [](const ShapePtr& other) -> bool {
0 commit comments