@@ -10,8 +10,9 @@ Date: April 2010
1010
1111#include " goto_rw.h"
1212
13- #include < limits>
1413#include < algorithm>
14+ #include < limits>
15+ #include < memory>
1516
1617#include < util/std_code.h>
1718#include < util/std_expr.h>
@@ -20,6 +21,7 @@ Date: April 2010
2021#include < util/endianness_map.h>
2122#include < util/arith_tools.h>
2223#include < util/simplify_expr.h>
24+ #include < util/make_unique.h>
2325
2426#include < goto-programs/goto_functions.h>
2527
@@ -49,12 +51,12 @@ rw_range_sett::~rw_range_sett()
4951 for (rw_range_sett::objectst::iterator it=r_range_set.begin ();
5052 it!=r_range_set.end ();
5153 ++it)
52- delete it->second ;
54+ it->second = nullptr ;
5355
5456 for (rw_range_sett::objectst::iterator it=w_range_set.begin ();
5557 it!=w_range_set.end ();
5658 ++it)
57- delete it->second ;
59+ it->second = nullptr ;
5860}
5961
6062void rw_range_sett::output (std::ostream &out) const
@@ -461,16 +463,18 @@ void rw_range_sett::add(
461463 const range_spect &range_start,
462464 const range_spect &range_end)
463465{
464- objectst::iterator entry=(mode==get_modet::LHS_W ? w_range_set : r_range_set).
465- insert (
466- std::pair<const irep_idt&, range_domain_baset*>(
467- identifier, nullptr )).first ;
466+ objectst::iterator entry=
467+ (mode==get_modet::LHS_W?w_range_set:r_range_set)
468+ .insert (
469+ std::pair<const irep_idt &, std::unique_ptr<range_domain_baset>>(
470+ identifier, nullptr ))
471+ .first ;
468472
469473 if (entry->second ==nullptr )
470- entry->second =new range_domaint ();
474+ entry->second =util_make_unique< range_domaint> ();
471475
472- static_cast <range_domaint*>( entry->second )-> push_back (
473- std::make_pair ( range_start, range_end) );
476+ static_cast <range_domaint&>(* entry->second ). push_back (
477+ { range_start, range_end} );
474478}
475479
476480void rw_range_sett::get_objects_rec (
@@ -662,17 +666,18 @@ void rw_guarded_range_set_value_sett::add(
662666 const range_spect &range_start,
663667 const range_spect &range_end)
664668{
665- objectst::iterator entry=(mode==get_modet::LHS_W ? w_range_set : r_range_set).
666- insert (
667- std::pair<const irep_idt&, range_domain_baset*>(
668- identifier, nullptr )).first ;
669+ objectst::iterator entry=
670+ (mode==get_modet::LHS_W?w_range_set:r_range_set)
671+ .insert (
672+ std::pair<const irep_idt &, std::unique_ptr<range_domain_baset>>(
673+ identifier, nullptr ))
674+ .first ;
669675
670676 if (entry->second ==nullptr )
671- entry->second =new guarded_range_domaint ();
677+ entry->second =util_make_unique< guarded_range_domaint> ();
672678
673- static_cast <guarded_range_domaint*>(entry->second )->insert (
674- std::make_pair (range_start,
675- std::make_pair (range_end, guard.as_expr ())));
679+ static_cast <guarded_range_domaint&>(*entry->second ).insert (
680+ {range_start, {range_end, guard.as_expr ()}});
676681}
677682
678683void goto_rw (goto_programt::const_targett target,
0 commit comments