diff options
author | David Malcolm <dmalcolm@redhat.com> | 2025-04-28 18:21:23 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2025-04-28 18:21:23 -0400 |
commit | cf5fb8f156b68b8a01e79a9471eeabebd499ea61 (patch) | |
tree | 76aede1f3629c95187c581c3a641fa72daaf52f8 /gcc/analyzer | |
parent | 6f9764571d2dd1b03e41be18b0bcd4fa445b958f (diff) | |
download | gcc-cf5fb8f156b68b8a01e79a9471eeabebd499ea61.zip gcc-cf5fb8f156b68b8a01e79a9471eeabebd499ea61.tar.gz gcc-cf5fb8f156b68b8a01e79a9471eeabebd499ea61.tar.bz2 |
Eliminate make-unique.h and ::make_unique
C++11 does not provide a std::make_unique so in
r13-3627-g00d7c8ff16e683 I added a make-unique.h
declaring a ::make_unique.
As of r15-4719-ga9ec1bc06bd3cc we can use C++14, so make-unique.h is no
longer needed: we can use simply use std::make_unique instead.
This patch removes make-unique.h and updates every place using it
to use std::make_unique.
No functional change intended.
gcc/analyzer/ChangeLog:
* access-diagram.cc: Replace uses of ::make_unique with
std::make_unique.
* analyzer.cc: Likewise.
* bounds-checking.cc: Likewise.
* call-details.cc: Likewise.
* call-info.cc: Likewise.
* call-string.cc: Likewise.
* checker-path.cc: Likewise.
* common.h: Drop include of "make-unique.h".
* constraint-manager.cc: Replace uses of ::make_unique with
std::make_unique.
* diagnostic-manager.cc: Likewise.
* engine.cc: Likewise.
* infinite-loop.cc: Likewise.
* infinite-recursion.cc: Likewise.
* kf-analyzer.cc: Likewise.
* kf-lang-cp.cc: Likewise.
* kf.cc: Likewise.
* pending-diagnostic.cc: Likewise.
* program-point.cc: Likewise; drop #include.
* program-state.cc: Likewise.
* ranges.cc: Likewise.
* region-model.cc: Likewise.
* region.cc: Likewise; drop #include.
* sm-fd.cc: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.cc: Likewise.
* store.cc: Likewise.
* supergraph.cc: Likewise.
* svalue.cc: Likewise; drop #include.
* varargs.cc: Likewise.
gcc/c-family/ChangeLog:
* c-pretty-print.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
gcc/c/ChangeLog:
* c-decl.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* c-objc-common.cc: Likewise.
* c-parser.cc: Likewise.
gcc/cp/ChangeLog:
* cxx-pretty-print.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* error.cc: Likewise.
* name-lookup.cc: Likewise.
* parser.cc: Likewise.
gcc/ChangeLog:
* diagnostic-format-json.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic.cc: Likewise.
* dumpfile.cc: Likewise.
* gcc-attribute-urlifier.cc: Likewise.
* gcc-urlifier.cc: Likewise.
* json-parsing.cc: Likewise.
* json.cc: Likewise.
* lazy-diagnostic-path.cc: Likewise.
* libgdiagnostics.cc: Likewise.
* libsarifreplay.cc: Likewise.
* lto-wrapper.cc: Likewise.
* make-unique.h: Delete.
* opts-diagnostic.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
* pretty-print.cc: Likewise.
* text-art/style.cc: Likewise.
* text-art/styled-string.cc: Likewise.
* text-art/table.cc: Likewise.
* text-art/tree-widget.cc: Likewise.
* text-art/widget.cc: Likewise.
* timevar.cc: Likewise.
* toplev.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
gcc/jit/ChangeLog:
* dummy-frontend.cc: Drop include of "make-unique.h".
Replace uses of ::make_unique with std::make_unique.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/analyzer_cpython_plugin.cc: Drop include of
"make-unique.h". Replace uses of ::make_unique with
std::make_unique.
* gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise.
* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise.
* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer')
34 files changed, 740 insertions, 689 deletions
diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc index a45268a..4283360 100644 --- a/gcc/analyzer/access-diagram.cc +++ b/gcc/analyzer/access-diagram.cc @@ -365,11 +365,11 @@ bit_size_expr::maybe_get_formatted_str (text_art::style_manager &sm, if (!wi::fits_uhwi_p (concrete_num_bytes)) return nullptr; if (concrete_num_bytes == 1) - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, concrete_single_byte_fmt, concrete_num_bytes.to_uhwi ())); else - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, concrete_plural_bytes_fmt, concrete_num_bytes.to_uhwi ())); } @@ -379,7 +379,7 @@ bit_size_expr::maybe_get_formatted_str (text_art::style_manager &sm, pp_format_decoder (&pp) = default_tree_printer; if (!num_bytes->maybe_print_for_user (&pp, model)) return nullptr; - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, symbolic_bytes_fmt, pp_formatted_text (&pp))); } @@ -390,11 +390,11 @@ bit_size_expr::maybe_get_formatted_str (text_art::style_manager &sm, if (!wi::fits_uhwi_p (concrete_num_bits)) return nullptr; if (concrete_num_bits == 1) - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, concrete_single_bit_fmt, concrete_num_bits.to_uhwi ())); else - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, concrete_plural_bits_fmt, concrete_num_bits.to_uhwi ())); } @@ -404,7 +404,7 @@ bit_size_expr::maybe_get_formatted_str (text_art::style_manager &sm, pp_format_decoder (&pp) = default_tree_printer; if (!m_num_bits.maybe_print_for_user (&pp, model)) return nullptr; - return ::make_unique <text_art::styled_string> + return std::make_unique <text_art::styled_string> (fmt_styled_string (sm, symbolic_bits_fmt, pp_formatted_text (&pp))); } @@ -1965,11 +1965,11 @@ make_written_svalue_spatial_item (const access_operation &op, if (const initial_svalue *initial_sval = sval.dyn_cast_initial_svalue ()) if (const string_region *string_reg = initial_sval->get_region ()->dyn_cast_string_region ()) - return make_unique <string_literal_spatial_item> + return std::make_unique <string_literal_spatial_item> (sval, actual_bits, *string_reg, theme, svalue_spatial_item::kind::WRITTEN); - return make_unique <written_svalue_spatial_item> (op, sval, actual_bits); + return std::make_unique <written_svalue_spatial_item> (op, sval, actual_bits); } static std::unique_ptr<spatial_item> @@ -1990,7 +1990,7 @@ make_existing_svalue_spatial_item (const svalue *sval, const initial_svalue *initial_sval = (const initial_svalue *)sval; if (const string_region *string_reg = initial_sval->get_region ()->dyn_cast_string_region ()) - return make_unique <string_literal_spatial_item> + return std::make_unique <string_literal_spatial_item> (*sval, bits, *string_reg, theme, svalue_spatial_item::kind::EXISTING); @@ -1998,7 +1998,7 @@ make_existing_svalue_spatial_item (const svalue *sval, } case SK_COMPOUND: - return make_unique<compound_svalue_spatial_item> + return std::make_unique<compound_svalue_spatial_item> (*((const compound_svalue *)sval), bits, svalue_spatial_item::kind::EXISTING, @@ -2106,7 +2106,7 @@ public: } m_col_widths - = make_unique <table_dimension_sizes> (m_btm.get_num_columns ()); + = std::make_unique <table_dimension_sizes> (m_btm.get_num_columns ()); /* Now create child widgets. */ @@ -2201,8 +2201,8 @@ private: std::unique_ptr<boundaries> find_boundaries () const { - std::unique_ptr<boundaries> result - = make_unique<boundaries> (*m_op.m_base_region, m_logger); + auto result + = std::make_unique<boundaries> (*m_op.m_base_region, m_logger); m_valid_region_spatial_item.add_boundaries (*result, m_logger); m_accessed_region_spatial_item.add_boundaries (*result, m_logger); @@ -2261,7 +2261,7 @@ private: void add_direction_widget () { - add_child (::make_unique<direction_widget> (*this, m_btm)); + add_child (std::make_unique<direction_widget> (*this, m_btm)); } void add_invalid_accesses_to_region_table (table &t_region) @@ -2666,11 +2666,12 @@ access_diagram::access_diagram (const access_operation &op, style_manager &sm, const theme &theme, logger *logger) -: wrapper_widget (make_unique <access_diagram_impl> (op, - region_creation_event_id, - sm, - theme, - logger)) +: wrapper_widget + (std::make_unique <access_diagram_impl> (op, + region_creation_event_id, + sm, + theme, + logger)) { } diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc index 88e53c7..c2814d2 100644 --- a/gcc/analyzer/analyzer.cc +++ b/gcc/analyzer/analyzer.cc @@ -219,11 +219,11 @@ std::unique_ptr<json::value> tree_to_json (tree node) { if (!node) - return ::make_unique<json::literal> (json::JSON_NULL); + return std::make_unique<json::literal> (json::JSON_NULL); pretty_printer pp; dump_generic_node (&pp, node, 0, TDF_VOPS|TDF_MEMSYMS, false); - return ::make_unique<json::string> (pp_formatted_text (&pp)); + return std::make_unique<json::string> (pp_formatted_text (&pp)); } /* Generate a JSON value for EVENT_ID. @@ -238,10 +238,10 @@ diagnostic_event_id_to_json (const diagnostic_event_id_t &event_id) { pretty_printer pp; pp_printf (&pp, "%@", &event_id); - return ::make_unique<json::string> (pp_formatted_text (&pp)); + return std::make_unique<json::string> (pp_formatted_text (&pp)); } else - return ::make_unique<json::literal> (json::JSON_NULL); + return std::make_unique<json::literal> (json::JSON_NULL); } /* Generate a JSON value for OFFSET. @@ -253,7 +253,7 @@ bit_offset_to_json (const bit_offset_t &offset) { pretty_printer pp; pp_wide_int_large (&pp, offset, SIGNED); - return ::make_unique<json::string> (pp_formatted_text (&pp)); + return std::make_unique<json::string> (pp_formatted_text (&pp)); } /* Generate a JSON value for OFFSET. @@ -265,7 +265,7 @@ byte_offset_to_json (const byte_offset_t &offset) { pretty_printer pp; pp_wide_int_large (&pp, offset, SIGNED); - return ::make_unique<json::string> (pp_formatted_text (&pp)); + return std::make_unique<json::string> (pp_formatted_text (&pp)); } /* Workaround for lack of const-correctness of ssa_default_def. */ diff --git a/gcc/analyzer/bounds-checking.cc b/gcc/analyzer/bounds-checking.cc index df7fab2..a3b1345 100644 --- a/gcc/analyzer/bounds-checking.cc +++ b/gcc/analyzer/bounds-checking.cc @@ -96,9 +96,9 @@ public: so we don't need an event for that. */ if (byte_capacity) emission_path.add_event - (make_unique<oob_region_creation_event_capacity> (byte_capacity, - loc_info, - *this)); + (std::make_unique<oob_region_creation_event_capacity> (byte_capacity, + loc_info, + *this)); } void maybe_add_sarif_properties (sarif_object &result_obj) @@ -289,9 +289,9 @@ public: { if (m_byte_bound && TREE_CODE (m_byte_bound) == INTEGER_CST) emission_path.add_event - (make_unique<oob_region_creation_event_capacity> (m_byte_bound, - loc_info, - *this)); + (std::make_unique<oob_region_creation_event_capacity> (m_byte_bound, + loc_info, + *this)); } void maybe_add_sarif_properties (sarif_object &result_obj) @@ -1420,22 +1420,24 @@ region_model::check_symbolic_bounds (const region *base_reg, break; case access_direction::read: gcc_assert (sval_hint == nullptr); - ctxt->warn (make_unique<symbolic_buffer_over_read> (*this, - sized_offset_reg, - diag_arg, - offset_tree, - num_bytes_tree, - capacity_tree)); + ctxt->warn + (std::make_unique<symbolic_buffer_over_read> (*this, + sized_offset_reg, + diag_arg, + offset_tree, + num_bytes_tree, + capacity_tree)); return false; break; case access_direction::write: - ctxt->warn (make_unique<symbolic_buffer_overflow> (*this, - sized_offset_reg, - diag_arg, - offset_tree, - num_bytes_tree, - capacity_tree, - sval_hint)); + ctxt->warn + (std::make_unique<symbolic_buffer_overflow> (*this, + sized_offset_reg, + diag_arg, + offset_tree, + num_bytes_tree, + capacity_tree, + sval_hint)); return false; break; } @@ -1528,16 +1530,18 @@ region_model::check_region_bounds (const region *reg, break; case access_direction::read: gcc_assert (sval_hint == nullptr); - ctxt->warn (make_unique<concrete_buffer_under_read> (*this, reg, - diag_arg, - bits_outside)); + ctxt->warn + (std::make_unique<concrete_buffer_under_read> (*this, reg, + diag_arg, + bits_outside)); oob_safe = false; break; case access_direction::write: - ctxt->warn (make_unique<concrete_buffer_underwrite> (*this, - reg, diag_arg, - bits_outside, - sval_hint)); + ctxt->warn + (std::make_unique<concrete_buffer_underwrite> (*this, + reg, diag_arg, + bits_outside, + sval_hint)); oob_safe = false; break; } @@ -1564,18 +1568,20 @@ region_model::check_region_bounds (const region *reg, break; case access_direction::read: gcc_assert (sval_hint == nullptr); - ctxt->warn (make_unique<concrete_buffer_over_read> (*this, - reg, diag_arg, - bits_outside, - bit_bound)); + ctxt->warn + (std::make_unique<concrete_buffer_over_read> (*this, + reg, diag_arg, + bits_outside, + bit_bound)); oob_safe = false; break; case access_direction::write: - ctxt->warn (make_unique<concrete_buffer_overflow> (*this, - reg, diag_arg, - bits_outside, - bit_bound, - sval_hint)); + ctxt->warn + (std::make_unique<concrete_buffer_overflow> (*this, + reg, diag_arg, + bits_outside, + bit_bound, + sval_hint)); oob_safe = false; break; } diff --git a/gcc/analyzer/call-details.cc b/gcc/analyzer/call-details.cc index 75e7341..bca8658 100644 --- a/gcc/analyzer/call-details.cc +++ b/gcc/analyzer/call-details.cc @@ -593,10 +593,10 @@ call_details::complain_about_overlap (unsigned arg_idx_a, if (!byte_range_a.intersection (byte_range_b, *model).is_true ()) return; - ctxt->warn (make_unique<overlapping_buffers> (get_fndecl_for_call (), - byte_range_a, - byte_range_b, - num_bytes_read_sval)); + ctxt->warn (std::make_unique<overlapping_buffers> (get_fndecl_for_call (), + byte_range_a, + byte_range_b, + num_bytes_read_sval)); } } // namespace ana diff --git a/gcc/analyzer/call-info.cc b/gcc/analyzer/call-info.cc index 0a5ae57..0e48c16 100644 --- a/gcc/analyzer/call-info.cc +++ b/gcc/analyzer/call-info.cc @@ -101,7 +101,7 @@ call_info::add_events_to_path (checker_path *emission_path, const int stack_depth = src_point.get_stack_depth (); emission_path->add_event - (make_unique<call_event> (event_loc_info (get_call_stmt ().location, + (std::make_unique<call_event> (event_loc_info (get_call_stmt ().location, caller_fndecl, stack_depth), this)); diff --git a/gcc/analyzer/call-string.cc b/gcc/analyzer/call-string.cc index 3a9829e..afa8004 100644 --- a/gcc/analyzer/call-string.cc +++ b/gcc/analyzer/call-string.cc @@ -91,11 +91,11 @@ call_string::print (pretty_printer *pp) const std::unique_ptr<json::value> call_string::to_json () const { - auto arr = ::make_unique<json::array> (); + auto arr = std::make_unique<json::array> (); for (const call_string::element_t &e : m_elements) { - auto e_obj = ::make_unique<json::object> (); + auto e_obj = std::make_unique<json::object> (); e_obj->set_integer ("src_snode_idx", e.m_callee->m_index); e_obj->set_integer ("dst_snode_idx", e.m_caller->m_index); e_obj->set_string ("funcname", function_name (e.m_caller->m_fun)); diff --git a/gcc/analyzer/checker-path.cc b/gcc/analyzer/checker-path.cc index e7a559f..9bde6f2 100644 --- a/gcc/analyzer/checker-path.cc +++ b/gcc/analyzer/checker-path.cc @@ -148,8 +148,8 @@ checker_path::add_region_creation_events (pending_diagnostic *pd, pd->add_region_creation_events (reg, capacity, loc_info, *this); if (debug) - add_event (make_unique<region_creation_event_debug> (reg, capacity, - loc_info)); + add_event (std::make_unique<region_creation_event_debug> (reg, capacity, + loc_info)); } void diff --git a/gcc/analyzer/common.h b/gcc/analyzer/common.h index 0dac29c..3d02b62 100644 --- a/gcc/analyzer/common.h +++ b/gcc/analyzer/common.h @@ -25,7 +25,6 @@ along with GCC; see the file COPYING3. If not see #define INCLUDE_VECTOR #include "system.h" #include "coretypes.h" -#include "make-unique.h" #include "tree.h" #include "function.h" #include "basic-block.h" diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index f39f054..a3e682c 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -436,7 +436,7 @@ bounded_range::dump (bool show_types) const std::unique_ptr<json::object> bounded_range::to_json () const { - auto range_obj = ::make_unique<json::object> (); + auto range_obj = std::make_unique<json::object> (); set_json_attr (*range_obj, "lower", m_lower); set_json_attr (*range_obj, "upper", m_upper); return range_obj; @@ -705,7 +705,7 @@ bounded_ranges::dump (bool show_types) const std::unique_ptr<json::value> bounded_ranges::to_json () const { - auto arr_obj = ::make_unique<json::array> (); + auto arr_obj = std::make_unique<json::array> (); for (unsigned i = 0; i < m_ranges.length (); ++i) arr_obj->append (m_ranges[i].to_json ()); @@ -1103,9 +1103,9 @@ equiv_class::print (pretty_printer *pp) const std::unique_ptr<json::object> equiv_class::to_json () const { - auto ec_obj = ::make_unique<json::object> (); + auto ec_obj = std::make_unique<json::object> (); - auto sval_arr = ::make_unique<json::array> (); + auto sval_arr = std::make_unique<json::array> (); for (const svalue *sval : m_vars) sval_arr->append (sval->to_json ()); ec_obj->set ("svals", std::move (sval_arr)); @@ -1370,7 +1370,7 @@ constraint::print (pretty_printer *pp, const constraint_manager &cm) const std::unique_ptr<json::object> constraint::to_json () const { - auto con_obj = ::make_unique<json::object> (); + auto con_obj = std::make_unique<json::object> (); con_obj->set_integer ("lhs", m_lhs.as_int ()); con_obj->set_string ("op", constraint_op_code (m_op)); @@ -1458,7 +1458,7 @@ bounded_ranges_constraint::print (pretty_printer *pp, std::unique_ptr<json::object> bounded_ranges_constraint::to_json () const { - auto con_obj = ::make_unique<json::object> (); + auto con_obj = std::make_unique<json::object> (); con_obj->set_integer ("ec", m_ec_id.as_int ()); con_obj->set ("ranges", m_ranges->to_json ()); @@ -1771,11 +1771,11 @@ debug (const constraint_manager &cm) std::unique_ptr<json::object> constraint_manager::to_json () const { - auto cm_obj = ::make_unique<json::object> (); + auto cm_obj = std::make_unique<json::object> (); /* Equivalence classes. */ { - auto ec_arr = ::make_unique<json::array> (); + auto ec_arr = std::make_unique<json::array> (); for (const equiv_class *ec : m_equiv_classes) ec_arr->append (ec->to_json ()); cm_obj->set ("ecs", std::move (ec_arr)); @@ -1783,7 +1783,7 @@ constraint_manager::to_json () const /* Constraints. */ { - auto con_arr = ::make_unique<json::array> (); + auto con_arr = std::make_unique<json::array> (); for (const constraint &c : m_constraints) con_arr->append (c.to_json ()); cm_obj->set ("constraints", std::move (con_arr)); @@ -1791,7 +1791,7 @@ constraint_manager::to_json () const /* m_bounded_ranges_constraints. */ { - auto con_arr = ::make_unique<json::array> (); + auto con_arr = std::make_unique<json::array> (); for (const auto &c : m_bounded_ranges_constraints) con_arr->append (c.to_json ()); cm_obj->set ("bounded_ranges_constraints", std::move (con_arr)); diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index 09629d4..161ae62 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -191,7 +191,7 @@ epath_finder::get_best_epath (const exploded_node *enode, logger->log ("trying to find shortest path ignoring feasibility"); gcc_assert (m_sep); std::unique_ptr<exploded_path> epath - = make_unique<exploded_path> (m_sep->get_shortest_path (enode)); + = std::make_unique<exploded_path> (m_sep->get_shortest_path (enode)); if (epath->feasible_p (logger, out_problem, m_eg.get_engine (), &m_eg)) { if (logger) @@ -730,7 +730,7 @@ saved_diagnostic::add_event (std::unique_ptr<checker_event> event) std::unique_ptr<json::object> saved_diagnostic::to_json () const { - auto sd_obj = ::make_unique<json::object> (); + auto sd_obj = std::make_unique<json::object> (); if (m_sm) sd_obj->set_string ("sm", m_sm->get_name ()); @@ -1036,10 +1036,10 @@ saved_diagnostic::maybe_add_sarif_properties (sarif_object &result_obj) const props.set_integer (PROPERTY_PREFIX "idx", m_idx); if (m_duplicates.length () > 0) { - auto duplicates_arr = ::make_unique<json::array> (); + auto duplicates_arr = std::make_unique<json::array> (); for (auto iter : m_duplicates) { - auto sd_obj = ::make_unique<sarif_object> (); + auto sd_obj = std::make_unique<sarif_object> (); iter->maybe_add_sarif_properties (*sd_obj); duplicates_arr->append (std::move (sd_obj)); } @@ -1230,10 +1230,10 @@ diagnostic_manager::add_event (std::unique_ptr<checker_event> event) std::unique_ptr<json::object> diagnostic_manager::to_json () const { - auto dm_obj = ::make_unique<json::object> (); + auto dm_obj = std::make_unique<json::object> (); { - auto sd_arr = ::make_unique<json::array> (); + auto sd_arr = std::make_unique<json::array> (); int i; saved_diagnostic *sd; FOR_EACH_VEC_ELT (m_saved_diagnostics, i, sd) @@ -1804,16 +1804,16 @@ public: int stack_depth = src_stack_depth; m_emission_path->add_event - (make_unique<state_change_event> (supernode, - stmt, - stack_depth, - sm, - nullptr, - src_sm_val, - dst_sm_val, - nullptr, - dst_state, - src_node)); + (std::make_unique<state_change_event> (supernode, + stmt, + stack_depth, + sm, + nullptr, + src_sm_val, + dst_sm_val, + nullptr, + dst_state, + src_node)); return false; } @@ -1849,16 +1849,16 @@ public: return false; m_emission_path->add_event - (make_unique<state_change_event> (supernode, - stmt, - stack_depth, - sm, - sval, - src_sm_val, - dst_sm_val, - dst_origin_sval, - dst_state, - src_node)); + (std::make_unique<state_change_event> (supernode, + stmt, + stack_depth, + sm, + sval, + src_sm_val, + dst_sm_val, + dst_origin_sval, + dst_state, + src_node)); return false; } @@ -1995,15 +1995,15 @@ struct null_assignment_sm_context : public sm_context int stack_depth = m_point->get_stack_depth (); m_emission_path->add_event - (make_unique<state_change_event> (supernode, - m_stmt, - stack_depth, - m_sm, - var_new_sval, - from, to, - nullptr, - *m_new_state, - nullptr)); + (std::make_unique<state_change_event> (supernode, + m_stmt, + stack_depth, + m_sm, + var_new_sval, + from, to, + nullptr, + *m_new_state, + nullptr)); } void set_next_state (const gimple *stmt, @@ -2021,15 +2021,15 @@ struct null_assignment_sm_context : public sm_context int stack_depth = m_point->get_stack_depth (); m_emission_path->add_event - (make_unique<state_change_event> (supernode, - m_stmt, - stack_depth, - m_sm, - sval, - from, to, - nullptr, - *m_new_state, - nullptr)); + (std::make_unique<state_change_event> (supernode, + m_stmt, + stack_depth, + m_sm, + sval, + from, to, + nullptr, + *m_new_state, + nullptr)); } void warn (const supernode *, const gimple *, @@ -2210,16 +2210,17 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb, const gcall *call = dyn_cast <const gcall *> (stmt); if (call && is_setjmp_call_p (*call)) emission_path->add_event - (make_unique<setjmp_event> (event_loc_info (stmt->location, - dst_point.get_fndecl (), - dst_stack_depth), - dst_node, - *call)); + (std::make_unique<setjmp_event> + (event_loc_info (stmt->location, + dst_point.get_fndecl (), + dst_stack_depth), + dst_node, + *call)); else emission_path->add_event - (make_unique<statement_event> (stmt, - dst_point.get_fndecl (), - dst_stack_depth, dst_state)); + (std::make_unique<statement_event> (stmt, + dst_point.get_fndecl (), + dst_stack_depth, dst_state)); /* Create state change events for assignment to NULL. Iterate through the stmts in dst_enode, adding state change @@ -2312,11 +2313,11 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb, " at this edge: "); pb.get_feasibility_problem ()->dump_to_pp (&pp); emission_path->add_event - (make_unique<precanned_custom_event> - (event_loc_info (dst_point.get_location (), - dst_point.get_fndecl (), - dst_stack_depth), - pp_formatted_text (&pp))); + (std::make_unique<precanned_custom_event> + (event_loc_info (dst_point.get_location (), + dst_point.get_fndecl (), + dst_stack_depth), + pp_formatted_text (&pp))); } } @@ -2427,17 +2428,18 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb, case SUPEREDGE_CFG_EDGE: { emission_path->add_event - (make_unique<start_cfg_edge_event> - (eedge, - event_loc_info (last_stmt ? last_stmt->location : UNKNOWN_LOCATION, - src_point.get_fndecl (), - src_stack_depth))); + (std::make_unique<start_cfg_edge_event> + (eedge, + event_loc_info + (last_stmt ? last_stmt->location : UNKNOWN_LOCATION, + src_point.get_fndecl (), + src_stack_depth))); emission_path->add_event - (make_unique<end_cfg_edge_event> - (eedge, - event_loc_info (dst_point.get_supernode ()->get_start_location (), - dst_point.get_fndecl (), - dst_stack_depth))); + (std::make_unique<end_cfg_edge_event> + (eedge, + event_loc_info (dst_point.get_supernode ()->get_start_location (), + dst_point.get_fndecl (), + dst_stack_depth))); } break; @@ -2450,12 +2452,13 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb, /* TODO: add a subclass for this, or generate events for the summary. */ emission_path->add_event - (make_unique<debug_event> (event_loc_info (last_stmt - ? last_stmt->location - : UNKNOWN_LOCATION, - src_point.get_fndecl (), - src_stack_depth), - "call summary")); + (std::make_unique<debug_event> + (event_loc_info (last_stmt + ? last_stmt->location + : UNKNOWN_LOCATION, + src_point.get_fndecl (), + src_stack_depth), + "call summary")); } break; @@ -2466,10 +2469,11 @@ diagnostic_manager::add_events_for_superedge (const path_builder &pb, const gcall &call_stmt = return_edge->get_call_stmt (); emission_path->add_event - (make_unique<return_event> (eedge, - event_loc_info (call_stmt.location, - dst_point.get_fndecl (), - dst_stack_depth))); + (std::make_unique<return_event> + (eedge, + event_loc_info (call_stmt.location, + dst_point.get_fndecl (), + dst_stack_depth))); } break; } diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index c04bda1..1b819ff 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -572,17 +572,17 @@ get_state_map_by_name (const char *name, { const sm_state_map *old_smap = m_old_state->m_checker_states[sm_idx]; *out_sm_context - = make_unique<impl_sm_context> (*m_eg, - sm_idx, - *sm, - m_enode_for_diag, - m_old_state, - m_new_state, - old_smap, - new_smap, - m_path_ctxt, - m_stmt_finder, - false); + = std::make_unique<impl_sm_context> (*m_eg, + sm_idx, + *sm, + m_enode_for_diag, + m_old_state, + m_new_state, + old_smap, + new_smap, + m_path_ctxt, + m_stmt_finder, + false); } return true; } @@ -598,7 +598,7 @@ public: std::unique_ptr<stmt_finder> clone () const final override { - return make_unique<leak_stmt_finder> (m_eg, m_var); + return std::make_unique<leak_stmt_finder> (m_eg, m_var); } const gimple *find_stmt (const exploded_path &epath) @@ -1429,7 +1429,7 @@ exploded_node::dump (const extrinsic_state &ext_state) const std::unique_ptr<json::object> exploded_node::to_json (const extrinsic_state &ext_state) const { - auto enode_obj = ::make_unique<json::object> (); + auto enode_obj = std::make_unique<json::object> (); enode_obj->set ("point", get_point ().to_json ()); enode_obj->set ("state", get_state ().to_json (ext_state)); @@ -1743,10 +1743,11 @@ exploded_node::replay_call_summary (exploded_graph &eg, call_summary_replay r (cd, called_fn, summary, ext_state); if (path_ctxt) - path_ctxt->bifurcate (make_unique<call_summary_edge_info> (cd, - called_fn, - summary, - ext_state)); + path_ctxt->bifurcate + (std::make_unique<call_summary_edge_info> (cd, + called_fn, + summary, + ext_state)); } @@ -1941,9 +1942,9 @@ exploded_node::on_longjmp (exploded_graph &eg, /* Verify that the setjmp's call_stack hasn't been popped. */ if (!valid_longjmp_stack_p (longjmp_point, setjmp_point)) { - ctxt->warn (make_unique<stale_jmp_buf> (setjmp_call, - longjmp_call, - setjmp_point)); + ctxt->warn (std::make_unique<stale_jmp_buf> (setjmp_call, + longjmp_call, + setjmp_point)); return; } @@ -1977,8 +1978,8 @@ exploded_node::on_longjmp (exploded_graph &eg, { exploded_edge *eedge = eg.add_edge (const_cast<exploded_node *> (this), next, NULL, true, - make_unique<rewind_info_t> (tmp_setjmp_record, - longjmp_call)); + std::make_unique<rewind_info_t> (tmp_setjmp_record, + longjmp_call)); /* For any diagnostics that were queued here (such as leaks) we want the checker_path to show the rewinding events after the "final event" @@ -2122,16 +2123,16 @@ dynamic_call_info_t::add_events_to_path (checker_path *emission_path, if (m_is_returning_call) emission_path->add_event - (make_unique<return_event> (eedge, - event_loc_info (m_dynamic_call.location, - dest_point.get_fndecl (), - dest_stack_depth))); + (std::make_unique<return_event> (eedge, + event_loc_info (m_dynamic_call.location, + dest_point.get_fndecl (), + dest_stack_depth))); else emission_path->add_event - (make_unique<call_event> (eedge, - event_loc_info (m_dynamic_call.location, - src_point.get_fndecl (), - src_stack_depth))); + (std::make_unique<call_event> (eedge, + event_loc_info (m_dynamic_call.location, + src_point.get_fndecl (), + src_stack_depth))); } /* class rewind_info_t : public custom_edge_info. */ @@ -2176,19 +2177,19 @@ rewind_info_t::add_events_to_path (checker_path *emission_path, const int dst_stack_depth = dst_point.get_stack_depth (); emission_path->add_event - (make_unique<rewind_from_longjmp_event> - (&eedge, - event_loc_info (get_longjmp_call ().location, - src_point.get_fndecl (), - src_stack_depth), - this)); + (std::make_unique<rewind_from_longjmp_event> + (&eedge, + event_loc_info (get_longjmp_call ().location, + src_point.get_fndecl (), + src_stack_depth), + this)); emission_path->add_event - (make_unique<rewind_to_setjmp_event> - (&eedge, - event_loc_info (get_setjmp_call ().location, - dst_point.get_fndecl (), - dst_stack_depth), - this)); + (std::make_unique<rewind_to_setjmp_event> + (&eedge, + event_loc_info (get_setjmp_call ().location, + dst_point.get_fndecl (), + dst_stack_depth), + this)); } /* class exploded_edge : public dedge<eg_traits>. */ @@ -2281,7 +2282,7 @@ exploded_edge::dump_dot_label (pretty_printer *pp) const std::unique_ptr<json::object> exploded_edge::to_json () const { - auto eedge_obj = ::make_unique<json::object> (); + auto eedge_obj = std::make_unique<json::object> (); eedge_obj->set_integer ("src_idx", m_src->m_index); eedge_obj->set_integer ("dst_idx", m_dest->m_index); if (m_sedge) @@ -2407,9 +2408,9 @@ strongly_connected_components::dump () const std::unique_ptr<json::array> strongly_connected_components::to_json () const { - auto scc_arr = ::make_unique<json::array> (); + auto scc_arr = std::make_unique<json::array> (); for (int i = 0; i < m_sg.num_nodes (); i++) - scc_arr->append (::make_unique<json::integer_number> (get_scc_id (i))); + scc_arr->append (std::make_unique<json::integer_number> (get_scc_id (i))); return scc_arr; } @@ -2628,7 +2629,7 @@ worklist::key_t::cmp (const worklist::key_t &ka, const worklist::key_t &kb) std::unique_ptr<json::object> worklist::to_json () const { - auto worklist_obj = ::make_unique<json::object> (); + auto worklist_obj = std::make_unique<json::object> (); worklist_obj->set ("scc", m_scc.to_json ()); @@ -2778,8 +2779,8 @@ public: const exploded_edge &) const final override { emission_path->add_event - (make_unique<tainted_args_function_custom_event> - (event_loc_info (DECL_SOURCE_LOCATION (m_fndecl), m_fndecl, 0))); + (std::make_unique<tainted_args_function_custom_event> + (event_loc_info (DECL_SOURCE_LOCATION (m_fndecl), m_fndecl, 0))); } private: @@ -2820,7 +2821,7 @@ exploded_graph::add_function_entry (const function &fun) if (lookup_attribute ("tainted_args", DECL_ATTRIBUTES (fun.decl))) { if (mark_params_as_tainted (&state, fun.decl, m_ext_state)) - edge_info = make_unique<tainted_args_function_info> (fun.decl); + edge_info = std::make_unique<tainted_args_function_info> (fun.decl); } if (!state.m_valid) @@ -3225,16 +3226,16 @@ public: /* Show the field in the struct declaration, e.g. "(1) field 'store' is marked with '__attribute__((tainted_args))'" */ emission_path->add_event - (make_unique<tainted_args_field_custom_event> (m_field)); + (std::make_unique<tainted_args_field_custom_event> (m_field)); /* Show the callback in the initializer e.g. "(2) function 'gadget_dev_desc_UDC_store' used as initializer for field 'store' marked with '__attribute__((tainted_args))'". */ emission_path->add_event - (make_unique<tainted_args_callback_custom_event> - (event_loc_info (m_loc, m_fndecl, 0), - m_field)); + (std::make_unique<tainted_args_callback_custom_event> + (event_loc_info (m_loc, m_fndecl, 0), + m_field)); } private: @@ -3291,7 +3292,7 @@ add_tainted_args_callback (exploded_graph *eg, tree field, tree fndecl, } eg->add_edge (eg->get_origin (), enode, NULL, false, - make_unique<tainted_args_call_info> (field, fndecl, loc)); + std::make_unique<tainted_args_call_info> (field, fndecl, loc)); } /* Callback for walk_tree for finding callbacks within initializers; @@ -3892,7 +3893,7 @@ exploded_graph::maybe_create_dynamic_call (const gcall &call, if (enode) add_edge (node,enode, NULL, false, /* No work is done by the call itself. */ - make_unique<dynamic_call_info_t> (call)); + std::make_unique<dynamic_call_info_t> (call)); return true; } } @@ -4362,7 +4363,8 @@ exploded_graph::process_node (exploded_node *node) const svalue *fn_ptr_sval = model->get_rvalue (fn_ptr, &ctxt); if (fn_ptr_sval->all_zeroes_p ()) - ctxt.warn (make_unique<jump_through_null> (call)); + ctxt.warn + (std::make_unique<jump_through_null> (call)); } /* An unknown function or a special function was called @@ -4429,7 +4431,7 @@ exploded_graph::process_node (exploded_node *node) node); if (enode) add_edge (node, enode, NULL, false, - make_unique<dynamic_call_info_t> (*call, true)); + std::make_unique<dynamic_call_info_t> (*call, true)); } } } @@ -4648,11 +4650,11 @@ exploded_graph::dump_states_for_supernode (FILE *out, std::unique_ptr<json::object> exploded_graph::to_json () const { - auto egraph_obj = ::make_unique<json::object> (); + auto egraph_obj = std::make_unique<json::object> (); /* Nodes. */ { - auto nodes_arr = ::make_unique<json::array> (); + auto nodes_arr = std::make_unique<json::array> (); unsigned i; exploded_node *n; FOR_EACH_VEC_ELT (m_nodes, i, n) @@ -4662,7 +4664,7 @@ exploded_graph::to_json () const /* Edges. */ { - auto edges_arr = ::make_unique<json::array> (); + auto edges_arr = std::make_unique<json::array> (); unsigned i; exploded_edge *n; FOR_EACH_VEC_ELT (m_edges, i, n) @@ -4768,9 +4770,9 @@ exploded_path::feasible_p (logger *logger, const program_point &src_point = src_enode.get_point (); const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt (); - *out = ::make_unique<feasibility_problem> (edge_idx, *eedge, - last_stmt, - std::move (rc)); + *out = std::make_unique<feasibility_problem> (edge_idx, *eedge, + last_stmt, + std::move (rc)); } return false; } @@ -6082,7 +6084,7 @@ dump_analyzer_json (const supergraph &sg, return; } - auto toplev_obj = ::make_unique<json::object> (); + auto toplev_obj = std::make_unique<json::object> (); toplev_obj->set ("sgraph", sg.to_json ()); toplev_obj->set ("egraph", eg.to_json ()); diff --git a/gcc/analyzer/infinite-loop.cc b/gcc/analyzer/infinite-loop.cc index 58927c7..ec0b079 100644 --- a/gcc/analyzer/infinite-loop.cc +++ b/gcc/analyzer/infinite-loop.cc @@ -86,9 +86,9 @@ struct infinite_loop std::unique_ptr<json::object> to_json () const { - auto loop_obj = ::make_unique<json::object> (); + auto loop_obj = std::make_unique<json::object> (); loop_obj->set_integer ("enode", m_enode.m_index); - auto edge_arr = ::make_unique<json::array> (); + auto edge_arr = std::make_unique<json::array> (); for (auto eedge : m_eedge_vec) edge_arr->append (eedge->to_json ()); loop_obj->set ("eedges", std::move (edge_arr)); @@ -215,7 +215,7 @@ public: checker_path *emission_path) final override { emission_path->add_event - (make_unique<warning_event> + (std::make_unique<warning_event> (event_loc_info (m_inf_loop->m_loc, enode->get_function ()->decl, enode->get_stack_depth ()), @@ -263,43 +263,46 @@ public: if (switch_cfg_sedge->implicitly_created_default_p ()) { emission_path->add_event - (make_unique<perpetual_start_cfg_edge_event> (*eedge, - loc_info_from)); + (std::make_unique<perpetual_start_cfg_edge_event> + (*eedge, + loc_info_from)); emission_path->add_event - (make_unique<end_cfg_edge_event> - (*eedge, - loc_info_to)); + (std::make_unique<end_cfg_edge_event> + (*eedge, + loc_info_to)); } } if (cfg_sedge->true_value_p ()) { emission_path->add_event - (make_unique<perpetual_start_cfg_edge_event> (*eedge, - loc_info_from)); + (std::make_unique<perpetual_start_cfg_edge_event> + (*eedge, + loc_info_from)); emission_path->add_event - (make_unique<end_cfg_edge_event> - (*eedge, - loc_info_to)); + (std::make_unique<end_cfg_edge_event> + (*eedge, + loc_info_to)); } else if (cfg_sedge->false_value_p ()) { emission_path->add_event - (make_unique<perpetual_start_cfg_edge_event> (*eedge, - loc_info_from)); + (std::make_unique<perpetual_start_cfg_edge_event> + (*eedge, + loc_info_from)); emission_path->add_event - (make_unique<end_cfg_edge_event> - (*eedge, - loc_info_to)); + (std::make_unique<end_cfg_edge_event> + (*eedge, + loc_info_to)); } else if (cfg_sedge->back_edge_p ()) { emission_path->add_event - (make_unique<looping_back_event> (*eedge, loc_info_from)); + (std::make_unique<looping_back_event> (*eedge, loc_info_from)); emission_path->add_event - (make_unique<end_cfg_edge_event> - (*eedge, - loc_info_to)); + (std::make_unique<end_cfg_edge_event> + (*eedge, + loc_info_to)); } } } @@ -393,7 +396,7 @@ starts_infinite_loop_p (const exploded_node &enode, feasible_node *curr_fnode = nullptr; if (flag_dump_analyzer_infinite_loop) - fg = ::make_unique<feasible_graph> (); + fg = std::make_unique<feasible_graph> (); location_t first_loc = UNKNOWN_LOCATION; const exploded_node *iter = &enode; @@ -438,10 +441,10 @@ starts_infinite_loop_p (const exploded_node &enode, fg->dump_dot (filename, nullptr, dump_args); free (filename); } - return ::make_unique<infinite_loop> (enode, - first_loc, - std::move (eedges), - logger); + return std::make_unique<infinite_loop> (enode, + first_loc, + std::move (eedges), + logger); } else { @@ -571,7 +574,7 @@ exploded_graph::detect_infinite_loops () pending_location ploc (enode, snode, inf_loop->m_loc); auto d - = ::make_unique<infinite_loop_diagnostic> (std::move (inf_loop)); + = std::make_unique<infinite_loop_diagnostic> (std::move (inf_loop)); get_diagnostic_manager ().add_diagnostic (ploc, std::move (d)); } } diff --git a/gcc/analyzer/infinite-recursion.cc b/gcc/analyzer/infinite-recursion.cc index 297b049..0641117 100644 --- a/gcc/analyzer/infinite-recursion.cc +++ b/gcc/analyzer/infinite-recursion.cc @@ -148,14 +148,15 @@ public: { gcc_assert (m_prev_entry_event == NULL); std::unique_ptr<checker_event> prev_entry_event - = make_unique <recursive_function_entry_event> (dst_point, - *this, false); + = std::make_unique <recursive_function_entry_event> (dst_point, + *this, false); m_prev_entry_event = prev_entry_event.get (); emission_path->add_event (std::move (prev_entry_event)); } else if (eedge.m_dest == m_new_entry_enode) emission_path->add_event - (make_unique<recursive_function_entry_event> (dst_point, *this, true)); + (std::make_unique<recursive_function_entry_event> + (dst_point, *this, true)); else pending_diagnostic::add_function_entry_event (eedge, emission_path); } @@ -171,7 +172,7 @@ public: { gcc_assert (m_new_entry_enode); emission_path->add_event - (make_unique<warning_event> + (std::make_unique<warning_event> (event_loc_info (m_new_entry_enode->get_supernode ()->get_start_location (), m_callee_fndecl, @@ -623,7 +624,7 @@ exploded_graph::detect_infinite_recursion (exploded_node *enode) nullptr); get_diagnostic_manager ().add_diagnostic (ploc, - make_unique<infinite_recursion_diagnostic> (prev_entry_enode, - enode, - fndecl)); + std::make_unique<infinite_recursion_diagnostic> (prev_entry_enode, + enode, + fndecl)); } diff --git a/gcc/analyzer/kf-analyzer.cc b/gcc/analyzer/kf-analyzer.cc index 669b497..3e671e5 100644 --- a/gcc/analyzer/kf-analyzer.cc +++ b/gcc/analyzer/kf-analyzer.cc @@ -297,7 +297,7 @@ public: region_model_context *ctxt = cd.get_ctxt (); if (!ctxt) return; - ctxt->warn (make_unique<dump_path_diagnostic> ()); + ctxt->warn (std::make_unique<dump_path_diagnostic> ()); } }; @@ -374,22 +374,28 @@ public: void register_known_analyzer_functions (known_function_manager &kfm) { - kfm.add ("__analyzer_break", make_unique<kf_analyzer_break> ()); - kfm.add ("__analyzer_describe", make_unique<kf_analyzer_describe> ()); + kfm.add ("__analyzer_break", + std::make_unique<kf_analyzer_break> ()); + kfm.add ("__analyzer_describe", + std::make_unique<kf_analyzer_describe> ()); kfm.add ("__analyzer_dump_capacity", - make_unique<kf_analyzer_dump_capacity> ()); - kfm.add ("__analyzer_dump_escaped", make_unique<kf_analyzer_dump_escaped> ()); + std::make_unique<kf_analyzer_dump_capacity> ()); + kfm.add ("__analyzer_dump_escaped", + std::make_unique<kf_analyzer_dump_escaped> ()); kfm.add ("__analyzer_dump_exploded_nodes", - make_unique<kf_analyzer_dump_exploded_nodes> ()); + std::make_unique<kf_analyzer_dump_exploded_nodes> ()); kfm.add ("__analyzer_dump_named_constant", - make_unique<kf_analyzer_dump_named_constant> ()); - kfm.add ("__analyzer_dump_path", make_unique<kf_analyzer_dump_path> ()); + std::make_unique<kf_analyzer_dump_named_constant> ()); + kfm.add ("__analyzer_dump_path", + std::make_unique<kf_analyzer_dump_path> ()); kfm.add ("__analyzer_dump_region_model", - make_unique<kf_analyzer_dump_region_model> ()); - kfm.add ("__analyzer_eval", make_unique<kf_analyzer_eval> ()); + std::make_unique<kf_analyzer_dump_region_model> ()); + kfm.add ("__analyzer_eval", + std::make_unique<kf_analyzer_eval> ()); kfm.add ("__analyzer_get_unknown_ptr", - make_unique<kf_analyzer_get_unknown_ptr> ()); - kfm.add ("__analyzer_get_strlen", make_kf_strlen ()); + std::make_unique<kf_analyzer_get_unknown_ptr> ()); + kfm.add ("__analyzer_get_strlen", + make_kf_strlen ()); } } // namespace ana diff --git a/gcc/analyzer/kf-lang-cp.cc b/gcc/analyzer/kf-lang-cp.cc index 8325f15..8e08dbc 100644 --- a/gcc/analyzer/kf-lang-cp.cc +++ b/gcc/analyzer/kf-lang-cp.cc @@ -172,10 +172,10 @@ public: void register_known_functions_lang_cp (known_function_manager &kfm) { - kfm.add ("operator new", make_unique<kf_operator_new> ()); - kfm.add ("operator new []", make_unique<kf_operator_new> ()); - kfm.add ("operator delete", make_unique<kf_operator_delete> ()); - kfm.add ("operator delete []", make_unique<kf_operator_delete> ()); + kfm.add ("operator new", std::make_unique<kf_operator_new> ()); + kfm.add ("operator new []", std::make_unique<kf_operator_new> ()); + kfm.add ("operator delete", std::make_unique<kf_operator_delete> ()); + kfm.add ("operator delete []", std::make_unique<kf_operator_delete> ()); } } // namespace ana diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc index e7f51ac..e9ad865 100644 --- a/gcc/analyzer/kf.cc +++ b/gcc/analyzer/kf.cc @@ -871,7 +871,7 @@ public: break; case MEMSPACE_STACK: if (ctxt) - ctxt->warn (make_unique<putenv_of_auto_var> (fndecl, reg)); + ctxt->warn (std::make_unique<putenv_of_auto_var> (fndecl, reg)); break; } cd.set_any_lhs_with_defaults (); @@ -1119,9 +1119,9 @@ kf_realloc::impl_call_post (const call_details &cd) const if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<failure> (cd)); - cd.get_ctxt ()->bifurcate (make_unique<success_no_move> (cd)); - cd.get_ctxt ()->bifurcate (make_unique<success_with_move> (cd)); + cd.get_ctxt ()->bifurcate (std::make_unique<failure> (cd)); + cd.get_ctxt ()->bifurcate (std::make_unique<success_no_move> (cd)); + cd.get_ctxt ()->bifurcate (std::make_unique<success_with_move> (cd)); cd.get_ctxt ()->terminate_path (); } } @@ -1210,8 +1210,8 @@ kf_strchr::impl_call_post (const call_details &cd) const /* Body of kf_strchr::impl_call_post. */ if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<strchr_call_info> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<strchr_call_info> (cd, true)); + cd.get_ctxt ()->bifurcate (std::make_unique<strchr_call_info> (cd, false)); + cd.get_ctxt ()->bifurcate (std::make_unique<strchr_call_info> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -1466,7 +1466,7 @@ public: std::unique_ptr<known_function> make_kf_strlen () { - return make_unique<kf_strlen> (); + return std::make_unique<kf_strlen> (); } /* Handler for "strncpy" and "__builtin_strncpy". @@ -1640,11 +1640,13 @@ kf_strncpy::impl_call_post (const call_details &cd) const nullptr, nullptr); cd.get_ctxt ()->bifurcate - (make_unique<strncpy_call_info> (cd, num_bytes_with_terminator_sval, - false)); + (std::make_unique<strncpy_call_info> + (cd, num_bytes_with_terminator_sval, + false)); cd.get_ctxt ()->bifurcate - (make_unique<strncpy_call_info> (cd, num_bytes_with_terminator_sval, - true)); + (std::make_unique<strncpy_call_info> + (cd, num_bytes_with_terminator_sval, + true)); cd.get_ctxt ()->terminate_path (); } }; @@ -1767,8 +1769,8 @@ kf_strstr::impl_call_post (const call_details &cd) const /* Body of kf_strstr::impl_call_post. */ if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<strstr_call_info> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<strstr_call_info> (cd, true)); + cd.get_ctxt ()->bifurcate (std::make_unique<strstr_call_info> (cd, false)); + cd.get_ctxt ()->bifurcate (std::make_unique<strstr_call_info> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -1914,7 +1916,7 @@ public: if (cd.get_arg_svalue (0)->all_zeroes_p ()) { if (ctxt) - ctxt->warn (::make_unique<undefined_behavior> (cd)); + ctxt->warn (::std::make_unique<undefined_behavior> (cd)); } /* Assume that "str" was actually non-null; terminate @@ -2032,13 +2034,13 @@ public: Typically the str is either null or non-null at a particular site, so hopefully this will generally just lead to two out-edges. */ cd.get_ctxt ()->bifurcate - (make_unique<strtok_call_info> (cd, m_private_reg, false, false)); + (std::make_unique<strtok_call_info> (cd, m_private_reg, false, false)); cd.get_ctxt ()->bifurcate - (make_unique<strtok_call_info> (cd, m_private_reg, false, true)); + (std::make_unique<strtok_call_info> (cd, m_private_reg, false, true)); cd.get_ctxt ()->bifurcate - (make_unique<strtok_call_info> (cd, m_private_reg, true, false)); + (std::make_unique<strtok_call_info> (cd, m_private_reg, true, false)); cd.get_ctxt ()->bifurcate - (make_unique<strtok_call_info> (cd, m_private_reg, true, true)); + (std::make_unique<strtok_call_info> (cd, m_private_reg, true, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2064,127 +2066,127 @@ region_model::impl_deallocation_call (const call_details &cd) static void register_atomic_builtins (known_function_manager &kfm) { - kfm.add (BUILT_IN_ATOMIC_EXCHANGE, make_unique<kf_atomic_exchange> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_N, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_1, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_2, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_4, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_8, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_EXCHANGE_16, make_unique<kf_atomic_exchange_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD, make_unique<kf_atomic_load> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_N, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_1, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_2, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_4, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_8, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_LOAD_16, make_unique<kf_atomic_load_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE, make_unique<kf_atomic_store> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_N, make_unique<kf_atomic_store_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_1, make_unique<kf_atomic_store_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_2, make_unique<kf_atomic_store_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_4, make_unique<kf_atomic_store_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_8, make_unique<kf_atomic_store_n> ()); - kfm.add (BUILT_IN_ATOMIC_STORE_16, make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE, std::make_unique<kf_atomic_exchange> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_N, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_1, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_2, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_4, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_8, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_EXCHANGE_16, std::make_unique<kf_atomic_exchange_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD, std::make_unique<kf_atomic_load> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_N, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_1, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_2, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_4, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_8, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_LOAD_16, std::make_unique<kf_atomic_load_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE, std::make_unique<kf_atomic_store> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_N, std::make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_1, std::make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_2, std::make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_4, std::make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_8, std::make_unique<kf_atomic_store_n> ()); + kfm.add (BUILT_IN_ATOMIC_STORE_16, std::make_unique<kf_atomic_store_n> ()); kfm.add (BUILT_IN_ATOMIC_ADD_FETCH_1, - make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_ADD_FETCH_2, - make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_ADD_FETCH_4, - make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_ADD_FETCH_8, - make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_ADD_FETCH_16, - make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_SUB_FETCH_1, - make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_SUB_FETCH_2, - make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_SUB_FETCH_4, - make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_SUB_FETCH_8, - make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_SUB_FETCH_16, - make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); + std::make_unique<kf_atomic_op_fetch> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_AND_FETCH_1, - make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_AND_FETCH_2, - make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_AND_FETCH_4, - make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_AND_FETCH_8, - make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_AND_FETCH_16, - make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_XOR_FETCH_1, - make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_XOR_FETCH_2, - make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_XOR_FETCH_4, - make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_XOR_FETCH_8, - make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_XOR_FETCH_16, - make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_OR_FETCH_1, - make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_OR_FETCH_2, - make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_OR_FETCH_4, - make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_OR_FETCH_8, - make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_OR_FETCH_16, - make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_op_fetch> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_ADD_1, - make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_ADD_2, - make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_ADD_4, - make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_ADD_8, - make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_ADD_16, - make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (PLUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_SUB_1, - make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_SUB_2, - make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_SUB_4, - make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_SUB_8, - make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_SUB_16, - make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); + std::make_unique<kf_atomic_fetch_op> (MINUS_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_AND_1, - make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_AND_2, - make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_AND_4, - make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_AND_8, - make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_AND_16, - make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_AND_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_XOR_1, - make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_XOR_2, - make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_XOR_4, - make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_XOR_8, - make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_XOR_16, - make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_XOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_OR_1, - make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_OR_2, - make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_OR_4, - make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_OR_8, - make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); kfm.add (BUILT_IN_ATOMIC_FETCH_OR_16, - make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); + std::make_unique<kf_atomic_fetch_op> (BIT_IOR_EXPR)); } /* Handle calls to the various IFN_UBSAN_* with no return value. @@ -2214,14 +2216,14 @@ register_sanitizer_builtins (known_function_manager &kfm) /* Handle calls to the various IFN_UBSAN_* with no return value. For now, treat these as no-ops. */ kfm.add (IFN_UBSAN_NULL, - make_unique<kf_ubsan_noop> ()); + std::make_unique<kf_ubsan_noop> ()); kfm.add (IFN_UBSAN_BOUNDS, - make_unique<kf_ubsan_noop> ()); + std::make_unique<kf_ubsan_noop> ()); kfm.add (IFN_UBSAN_PTR, - make_unique<kf_ubsan_noop> ()); + std::make_unique<kf_ubsan_noop> ()); kfm.add (BUILT_IN_UBSAN_HANDLE_NONNULL_ARG, - make_unique<kf_ubsan_handler> ()); + std::make_unique<kf_ubsan_handler> ()); } /* Populate KFM with instances of known functions supported by the core of the @@ -2236,17 +2238,17 @@ register_known_functions (known_function_manager &kfm, /* Internal fns the analyzer has known_functions for. */ { - kfm.add (IFN_BUILTIN_EXPECT, make_unique<kf_expect> ()); + kfm.add (IFN_BUILTIN_EXPECT, std::make_unique<kf_expect> ()); } /* GCC built-ins that do not correspond to a function in the standard library. */ { - kfm.add (BUILT_IN_EXPECT, make_unique<kf_expect> ()); - kfm.add (BUILT_IN_EXPECT_WITH_PROBABILITY, make_unique<kf_expect> ()); - kfm.add (BUILT_IN_ALLOCA_WITH_ALIGN, make_unique<kf_alloca> ()); - kfm.add (BUILT_IN_STACK_RESTORE, make_unique<kf_stack_restore> ()); - kfm.add (BUILT_IN_STACK_SAVE, make_unique<kf_stack_save> ()); + kfm.add (BUILT_IN_EXPECT, std::make_unique<kf_expect> ()); + kfm.add (BUILT_IN_EXPECT_WITH_PROBABILITY, std::make_unique<kf_expect> ()); + kfm.add (BUILT_IN_ALLOCA_WITH_ALIGN, std::make_unique<kf_alloca> ()); + kfm.add (BUILT_IN_STACK_RESTORE, std::make_unique<kf_stack_restore> ()); + kfm.add (BUILT_IN_STACK_SAVE, std::make_unique<kf_stack_save> ()); register_atomic_builtins (kfm); register_sanitizer_builtins (kfm); @@ -2256,58 +2258,58 @@ register_known_functions (known_function_manager &kfm, /* Known builtins and C standard library functions the analyzer has known functions for. */ { - kfm.add ("alloca", make_unique<kf_alloca> ()); - kfm.add ("__builtin_alloca", make_unique<kf_alloca> ()); - kfm.add ("calloc", make_unique<kf_calloc> ()); - kfm.add ("__builtin_calloc", make_unique<kf_calloc> ()); - kfm.add ("free", make_unique<kf_free> ()); - kfm.add ("__builtin_free", make_unique<kf_free> ()); - kfm.add ("malloc", make_unique<kf_malloc> ()); - kfm.add ("__builtin_malloc", make_unique<kf_malloc> ()); + kfm.add ("alloca", std::make_unique<kf_alloca> ()); + kfm.add ("__builtin_alloca", std::make_unique<kf_alloca> ()); + kfm.add ("calloc", std::make_unique<kf_calloc> ()); + kfm.add ("__builtin_calloc", std::make_unique<kf_calloc> ()); + kfm.add ("free", std::make_unique<kf_free> ()); + kfm.add ("__builtin_free", std::make_unique<kf_free> ()); + kfm.add ("malloc", std::make_unique<kf_malloc> ()); + kfm.add ("__builtin_malloc", std::make_unique<kf_malloc> ()); kfm.add ("memcpy", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); kfm.add ("__builtin_memcpy", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); - kfm.add ("__memcpy_chk", make_unique<kf_memcpy_memmove> + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); + kfm.add ("__memcpy_chk", std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY_CHK)); - kfm.add ("__builtin___memcpy_chk", make_unique<kf_memcpy_memmove> + kfm.add ("__builtin___memcpy_chk", std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY_CHK)); kfm.add ("memmove", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); kfm.add ("__builtin_memmove", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); - kfm.add ("__memmove_chk", make_unique<kf_memcpy_memmove> + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); + kfm.add ("__memmove_chk", std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE_CHK)); - kfm.add ("__builtin___memmove_chk", make_unique<kf_memcpy_memmove> + kfm.add ("__builtin___memmove_chk", std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE_CHK)); - kfm.add ("memset", make_unique<kf_memset> (false)); - kfm.add ("__builtin_memset", make_unique<kf_memset> (false)); - kfm.add ("__memset_chk", make_unique<kf_memset> (true)); - kfm.add ("__builtin___memset_chk", make_unique<kf_memset> (true)); - kfm.add ("realloc", make_unique<kf_realloc> ()); - kfm.add ("__builtin_realloc", make_unique<kf_realloc> ()); - kfm.add ("sprintf", make_unique<kf_sprintf> ()); - kfm.add ("__builtin_sprintf", make_unique<kf_sprintf> ()); - kfm.add ("strchr", make_unique<kf_strchr> ()); - kfm.add ("__builtin_strchr", make_unique<kf_strchr> ()); - kfm.add ("strcpy", make_unique<kf_strcpy> (2, false)); - kfm.add ("__builtin_strcpy", make_unique<kf_strcpy> (2, false)); - kfm.add ("__strcpy_chk", make_unique<kf_strcpy> (3, true)); - kfm.add ("__builtin___strcpy_chk", make_unique<kf_strcpy> (3, true)); - kfm.add ("strcat", make_unique<kf_strcat> (2, false)); - kfm.add ("__builtin_strcat", make_unique<kf_strcat> (2, false)); - kfm.add ("__strcat_chk", make_unique<kf_strcat> (3, true)); - kfm.add ("__builtin___strcat_chk", make_unique<kf_strcat> (3, true)); - kfm.add ("strdup", make_unique<kf_strdup> ()); - kfm.add ("__builtin_strdup", make_unique<kf_strdup> ()); - kfm.add ("strncpy", make_unique<kf_strncpy> ()); - kfm.add ("__builtin_strncpy", make_unique<kf_strncpy> ()); - kfm.add ("strndup", make_unique<kf_strndup> ()); - kfm.add ("__builtin_strndup", make_unique<kf_strndup> ()); - kfm.add ("strlen", make_unique<kf_strlen> ()); - kfm.add ("__builtin_strlen", make_unique<kf_strlen> ()); - kfm.add ("strstr", make_unique<kf_strstr> ()); - kfm.add ("__builtin_strstr", make_unique<kf_strstr> ()); + kfm.add ("memset", std::make_unique<kf_memset> (false)); + kfm.add ("__builtin_memset", std::make_unique<kf_memset> (false)); + kfm.add ("__memset_chk", std::make_unique<kf_memset> (true)); + kfm.add ("__builtin___memset_chk", std::make_unique<kf_memset> (true)); + kfm.add ("realloc", std::make_unique<kf_realloc> ()); + kfm.add ("__builtin_realloc", std::make_unique<kf_realloc> ()); + kfm.add ("sprintf", std::make_unique<kf_sprintf> ()); + kfm.add ("__builtin_sprintf", std::make_unique<kf_sprintf> ()); + kfm.add ("strchr", std::make_unique<kf_strchr> ()); + kfm.add ("__builtin_strchr", std::make_unique<kf_strchr> ()); + kfm.add ("strcpy", std::make_unique<kf_strcpy> (2, false)); + kfm.add ("__builtin_strcpy", std::make_unique<kf_strcpy> (2, false)); + kfm.add ("__strcpy_chk", std::make_unique<kf_strcpy> (3, true)); + kfm.add ("__builtin___strcpy_chk", std::make_unique<kf_strcpy> (3, true)); + kfm.add ("strcat", std::make_unique<kf_strcat> (2, false)); + kfm.add ("__builtin_strcat", std::make_unique<kf_strcat> (2, false)); + kfm.add ("__strcat_chk", std::make_unique<kf_strcat> (3, true)); + kfm.add ("__builtin___strcat_chk", std::make_unique<kf_strcat> (3, true)); + kfm.add ("strdup", std::make_unique<kf_strdup> ()); + kfm.add ("__builtin_strdup", std::make_unique<kf_strdup> ()); + kfm.add ("strncpy", std::make_unique<kf_strncpy> ()); + kfm.add ("__builtin_strncpy", std::make_unique<kf_strncpy> ()); + kfm.add ("strndup", std::make_unique<kf_strndup> ()); + kfm.add ("__builtin_strndup", std::make_unique<kf_strndup> ()); + kfm.add ("strlen", std::make_unique<kf_strlen> ()); + kfm.add ("__builtin_strlen", std::make_unique<kf_strlen> ()); + kfm.add ("strstr", std::make_unique<kf_strstr> ()); + kfm.add ("__builtin_strstr", std::make_unique<kf_strstr> ()); register_atomic_builtins (kfm); register_varargs_builtins (kfm); @@ -2315,9 +2317,9 @@ register_known_functions (known_function_manager &kfm, /* Known POSIX functions, and some non-standard extensions. */ { - kfm.add ("fopen", make_unique<kf_fopen> ()); - kfm.add ("putenv", make_unique<kf_putenv> ()); - kfm.add ("strtok", make_unique<kf_strtok> (rmm)); + kfm.add ("fopen", std::make_unique<kf_fopen> ()); + kfm.add ("putenv", std::make_unique<kf_putenv> ()); + kfm.add ("strtok", std::make_unique<kf_strtok> (rmm)); register_known_fd_functions (kfm); register_known_file_functions (kfm); @@ -2325,13 +2327,13 @@ register_known_functions (known_function_manager &kfm, /* glibc functions. */ { - kfm.add ("__errno_location", make_unique<kf_errno_location> ()); - kfm.add ("error", make_unique<kf_error> (3)); - kfm.add ("error_at_line", make_unique<kf_error> (5)); + kfm.add ("__errno_location", std::make_unique<kf_errno_location> ()); + kfm.add ("error", std::make_unique<kf_error> (3)); + kfm.add ("error_at_line", std::make_unique<kf_error> (5)); /* Variants of "error" and "error_at_line" seen by the analyzer at -O0 (PR analyzer/115724). */ - kfm.add ("__error_alias", make_unique<kf_error> (3)); - kfm.add ("__error_at_line_alias", make_unique<kf_error> (5)); + kfm.add ("__error_alias", std::make_unique<kf_error> (3)); + kfm.add ("__error_at_line_alias", std::make_unique<kf_error> (5)); } /* Other implementations of C standard library. */ @@ -2345,9 +2347,9 @@ register_known_functions (known_function_manager &kfm, #define errno (*__error()) and similarly __errno for newlib. Add these as synonyms for "__errno_location". */ - kfm.add ("___errno", make_unique<kf_errno_location> ()); - kfm.add ("__error", make_unique<kf_errno_location> ()); - kfm.add ("__errno", make_unique<kf_errno_location> ()); + kfm.add ("___errno", std::make_unique<kf_errno_location> ()); + kfm.add ("__error", std::make_unique<kf_errno_location> ()); + kfm.add ("__errno", std::make_unique<kf_errno_location> ()); } /* Language-specific support functions. */ @@ -2357,22 +2359,22 @@ register_known_functions (known_function_manager &kfm, from <cstdlib> etc for the C spellings of these headers (e.g. <stdlib.h>), so we must match against these too. */ { - kfm.add_std_ns ("malloc", make_unique<kf_malloc> ()); - kfm.add_std_ns ("free", make_unique<kf_free> ()); - kfm.add_std_ns ("realloc", make_unique<kf_realloc> ()); - kfm.add_std_ns ("calloc", make_unique<kf_calloc> ()); + kfm.add_std_ns ("malloc", std::make_unique<kf_malloc> ()); + kfm.add_std_ns ("free", std::make_unique<kf_free> ()); + kfm.add_std_ns ("realloc", std::make_unique<kf_realloc> ()); + kfm.add_std_ns ("calloc", std::make_unique<kf_calloc> ()); kfm.add_std_ns ("memcpy", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMCPY)); kfm.add_std_ns ("memmove", - make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); - kfm.add_std_ns ("memset", make_unique<kf_memset> (false)); - kfm.add_std_ns ("strcat", make_unique<kf_strcat> (2, false)); - kfm.add_std_ns ("strcpy", make_unique<kf_strcpy> (2, false)); - kfm.add_std_ns ("strlen", make_unique<kf_strlen> ()); - kfm.add_std_ns ("strncpy", make_unique<kf_strncpy> ()); - kfm.add_std_ns ("strtok", make_unique<kf_strtok> (rmm)); + std::make_unique<kf_memcpy_memmove> (kf_memcpy_memmove::KF_MEMMOVE)); + kfm.add_std_ns ("memset", std::make_unique<kf_memset> (false)); + kfm.add_std_ns ("strcat", std::make_unique<kf_strcat> (2, false)); + kfm.add_std_ns ("strcpy", std::make_unique<kf_strcpy> (2, false)); + kfm.add_std_ns ("strlen", std::make_unique<kf_strlen> ()); + kfm.add_std_ns ("strncpy", std::make_unique<kf_strncpy> ()); + kfm.add_std_ns ("strtok", std::make_unique<kf_strtok> (rmm)); } } diff --git a/gcc/analyzer/pending-diagnostic.cc b/gcc/analyzer/pending-diagnostic.cc index 452453a..70dc815 100644 --- a/gcc/analyzer/pending-diagnostic.cc +++ b/gcc/analyzer/pending-diagnostic.cc @@ -185,7 +185,7 @@ pending_diagnostic::add_function_entry_event (const exploded_edge &eedge, { const exploded_node *dst_node = eedge.m_dest; const program_point &dst_point = dst_node->get_point (); - emission_path->add_event (make_unique<function_entry_event> (dst_point)); + emission_path->add_event (std::make_unique<function_entry_event> (dst_point)); } /* Base implementation of pending_diagnostic::add_call_event. @@ -200,12 +200,12 @@ pending_diagnostic::add_call_event (const exploded_edge &eedge, const int src_stack_depth = src_point.get_stack_depth (); const gimple *last_stmt = src_point.get_supernode ()->get_last_stmt (); emission_path->add_event - (make_unique<call_event> (eedge, - event_loc_info (last_stmt - ? last_stmt->location - : UNKNOWN_LOCATION, - src_point.get_fndecl (), - src_stack_depth))); + (std::make_unique<call_event> (eedge, + event_loc_info (last_stmt + ? last_stmt->location + : UNKNOWN_LOCATION, + src_point.get_fndecl (), + src_stack_depth))); } /* Base implementation of pending_diagnostic::add_region_creation_events. @@ -218,12 +218,13 @@ pending_diagnostic::add_region_creation_events (const region *reg, checker_path &emission_path) { emission_path.add_event - (make_unique<region_creation_event_memory_space> (reg->get_memory_space (), - loc_info)); + (std::make_unique<region_creation_event_memory_space> + (reg->get_memory_space (), + loc_info)); if (capacity) emission_path.add_event - (make_unique<region_creation_event_capacity> (capacity, loc_info)); + (std::make_unique<region_creation_event_capacity> (capacity, loc_info)); } /* Base implementation of pending_diagnostic::add_final_event. @@ -237,7 +238,7 @@ pending_diagnostic::add_final_event (const state_machine *sm, checker_path *emission_path) { emission_path->add_event - (make_unique<warning_event> + (std::make_unique<warning_event> (loc_info, enode, sm, var, state)); diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc index e72c2e2..c95f863 100644 --- a/gcc/analyzer/program-point.cc +++ b/gcc/analyzer/program-point.cc @@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-event-id.h" #include "gcc-rich-location.h" #include "gimple-pretty-print.h" -#include "make-unique.h" #include "sbitmap.h" #include "selftest.h" #include "shortest-paths.h" @@ -303,7 +302,7 @@ program_point::dump () const std::unique_ptr<json::object> program_point::to_json () const { - auto point_obj = ::make_unique<json::object> (); + auto point_obj = std::make_unique<json::object> (); point_obj->set_string ("kind", point_kind_to_string (get_kind ())); diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 4d3fec0..dbca036 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -92,10 +92,10 @@ extrinsic_state::dump () const std::unique_ptr<json::object> extrinsic_state::to_json () const { - auto ext_state_obj = ::make_unique<json::object> (); + auto ext_state_obj = std::make_unique<json::object> (); { - auto checkers_arr = ::make_unique<json::array> (); + auto checkers_arr = std::make_unique<json::array> (); for (auto &sm : m_checkers) checkers_arr->append (sm->to_json ()); ext_state_obj->set ("checkers", std::move (checkers_arr)); @@ -266,7 +266,7 @@ sm_state_map::dump (bool simple) const std::unique_ptr<json::object> sm_state_map::to_json () const { - auto map_obj = ::make_unique<json::object> (); + auto map_obj = std::make_unique<json::object> (); if (m_global_state != m_sm.get_start_state ()) map_obj->set ("global", m_global_state->to_json ()); @@ -1175,7 +1175,7 @@ program_state::dump () const std::unique_ptr<json::object> program_state::to_json (const extrinsic_state &ext_state) const { - auto state_obj = ::make_unique<json::object> (); + auto state_obj = std::make_unique<json::object> (); state_obj->set ("store", m_region_model->get_store ()->to_json ()); state_obj->set ("constraints", @@ -1186,7 +1186,7 @@ program_state::to_json (const extrinsic_state &ext_state) const /* Provide m_checker_states as an object, using names as keys. */ { - auto checkers_obj = ::make_unique<json::object> (); + auto checkers_obj = std::make_unique<json::object> (); int i; sm_state_map *smap; diff --git a/gcc/analyzer/ranges.cc b/gcc/analyzer/ranges.cc index 64e351f..1a960fa 100644 --- a/gcc/analyzer/ranges.cc +++ b/gcc/analyzer/ranges.cc @@ -136,7 +136,7 @@ symbolic_byte_range::dump (bool simple, region_model_manager &mgr) const std::unique_ptr<json::value> symbolic_byte_range::to_json () const { - auto obj = ::make_unique<json::object> (); + auto obj = std::make_unique<json::object> (); obj->set ("start", m_start.to_json ()); obj->set ("size", m_size.to_json ()); return obj; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index b65efad..ea0e6b0 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -217,7 +217,7 @@ region_to_value_map::dump (bool simple) const std::unique_ptr<json::object> region_to_value_map::to_json () const { - auto map_obj = ::make_unique<json::object> (); + auto map_obj = std::make_unique<json::object> (); auto_vec<const region *> regs; for (iterator iter = begin (); iter != end (); ++iter) @@ -497,7 +497,7 @@ region_model::debug () const std::unique_ptr<json::object> region_model::to_json () const { - auto model_obj = ::make_unique<json::object> (); + auto model_obj = std::make_unique<json::object> (); model_obj->set ("store", m_store.to_json ()); model_obj->set ("constraints", m_constraints->to_json ()); if (m_current_frame) @@ -938,10 +938,10 @@ public: { if (reg == m_base_reg_a) emission_path.add_event - (make_unique<ptrdiff_region_creation_event> (loc_info, true)); + (std::make_unique<ptrdiff_region_creation_event> (loc_info, true)); else if (reg == m_base_reg_b) emission_path.add_event - (make_unique<ptrdiff_region_creation_event> (loc_info, false)); + (std::make_unique<ptrdiff_region_creation_event> (loc_info, false)); } bool @@ -991,11 +991,12 @@ check_for_invalid_ptrdiff (const gassign *assign, if (base_reg_b->get_kind () == RK_SYMBOLIC) return; - ctxt.warn (make_unique<undefined_ptrdiff_diagnostic> (assign, - sval_a, - sval_b, - base_reg_a, - base_reg_b)); + ctxt.warn + (std::make_unique<undefined_ptrdiff_diagnostic> (assign, + sval_a, + sval_b, + base_reg_a, + base_reg_b)); } /* If ASSIGN is a stmt that can be modelled via @@ -1174,13 +1175,13 @@ region_model::get_gassign_result (const gassign *assign, { if (tree_int_cst_sgn (rhs2_cst) < 0) ctxt->warn - (make_unique<shift_count_negative_diagnostic> + (std::make_unique<shift_count_negative_diagnostic> (assign, rhs2_cst)); else if (compare_tree_int (rhs2_cst, TYPE_PRECISION (TREE_TYPE (rhs1))) >= 0) ctxt->warn - (make_unique<shift_count_overflow_diagnostic> + (std::make_unique<shift_count_overflow_diagnostic> (assign, int (TYPE_PRECISION (TREE_TYPE (rhs1))), rhs2_cst)); @@ -1414,10 +1415,11 @@ region_model::check_for_poison (const svalue *sval, check_expr = expr; else check_expr = NULL; - if (ctxt->warn (make_unique<poisoned_value_diagnostic> (diag_arg, - pkind, - src_region, - check_expr))) + if (ctxt->warn + (std::make_unique<poisoned_value_diagnostic> (diag_arg, + pkind, + src_region, + check_expr))) { /* We only want to report use of a poisoned value at the first place it gets used; return an unknown value to avoid generating @@ -1680,7 +1682,7 @@ region_model::check_call_format_attr (const call_details &cd, }; call_arg_details arg_details (m_cd, m_fmt_param_idx); - add_note (make_unique<reason_format_attr> (arg_details)); + add_note (std::make_unique<reason_format_attr> (arg_details)); } private: const call_details &m_cd; @@ -2135,8 +2137,8 @@ region_model::check_function_attr_access (const gcall &call, } void add_annotations () final override { - add_note (make_unique<reason_attr_access> - (m_callee_fndecl, m_access)); + add_note (std::make_unique<reason_attr_access> + (m_callee_fndecl, m_access)); } private: tree m_callee_fndecl; @@ -3080,7 +3082,7 @@ region_model::deref_rvalue (const svalue *ptr_sval, tree ptr_tree, const poisoned_svalue *poisoned_sval = as_a <const poisoned_svalue *> (ptr_sval); enum poison_kind pkind = poisoned_sval->get_poison_kind (); - ctxt->warn (::make_unique<poisoned_value_diagnostic> + ctxt->warn (std::make_unique<poisoned_value_diagnostic> (ptr, pkind, nullptr, nullptr)); } } @@ -3251,16 +3253,18 @@ region_model::check_for_writable_region (const region* dest_reg, { const function_region *func_reg = as_a <const function_region *> (base_reg); tree fndecl = func_reg->get_fndecl (); - ctxt->warn (make_unique<write_to_const_diagnostic> - (func_reg, fndecl)); + ctxt->warn + (std::make_unique<write_to_const_diagnostic> + (func_reg, fndecl)); } break; case RK_LABEL: { const label_region *label_reg = as_a <const label_region *> (base_reg); tree label = label_reg->get_label (); - ctxt->warn (make_unique<write_to_const_diagnostic> - (label_reg, label)); + ctxt->warn + (std::make_unique<write_to_const_diagnostic> + (label_reg, label)); } break; case RK_DECL: @@ -3273,11 +3277,13 @@ region_model::check_for_writable_region (const region* dest_reg, "this" param is "T* const"). */ if (TREE_READONLY (decl) && is_global_var (decl)) - ctxt->warn (make_unique<write_to_const_diagnostic> (dest_reg, decl)); + ctxt->warn + (std::make_unique<write_to_const_diagnostic> (dest_reg, decl)); } break; case RK_STRING: - ctxt->warn (make_unique<write_to_string_literal_diagnostic> (dest_reg)); + ctxt->warn + (std::make_unique<write_to_string_literal_diagnostic> (dest_reg)); break; } } @@ -3479,7 +3485,8 @@ public: checker_path &emission_path) final override { emission_path.add_event - (make_unique<region_creation_event_allocation_size> (capacity, loc_info)); + (std::make_unique<region_creation_event_allocation_size> + (capacity, loc_info)); m_has_allocation_event = true; } @@ -3815,9 +3822,10 @@ region_model::check_region_size (const region *lhs_reg, const svalue *rhs_sval, if (TREE_CODE (cst_cap) == INTEGER_CST && !capacity_compatible_with_type (cst_cap, pointee_size_tree, is_struct)) - ctxt->warn (make_unique <dubious_allocation_size> (lhs_reg, rhs_reg, - capacity, cst_cap, - ctxt->get_stmt ())); + ctxt->warn + (std::make_unique <dubious_allocation_size> (lhs_reg, rhs_reg, + capacity, cst_cap, + ctxt->get_stmt ())); } break; default: @@ -3829,10 +3837,11 @@ region_model::check_region_size (const region *lhs_reg, const svalue *rhs_sval, m_constraints)) { tree expr = get_representative_tree (capacity); - ctxt->warn (make_unique <dubious_allocation_size> (lhs_reg, - rhs_reg, - capacity, expr, - ctxt->get_stmt ())); + ctxt->warn + (std::make_unique <dubious_allocation_size> (lhs_reg, + rhs_reg, + capacity, expr, + ctxt->get_stmt ())); } } break; @@ -4625,9 +4634,11 @@ region_model::check_for_null_terminated_string_arg (const call_details &cd, m_cd.get_model ()->get_current_function ()->decl, m_cd.get_model ()->get_stack_depth ()); - add_event (make_unique<null_terminator_check_event> (loc_info, - arg_details)); - add_note (make_unique <null_terminator_check_decl_note> (arg_details)); + add_event + (std::make_unique<null_terminator_check_event> (loc_info, + arg_details)); + add_note + (std::make_unique <null_terminator_check_decl_note> (arg_details)); } private: const call_details &m_cd; @@ -5373,7 +5384,7 @@ region_model::add_constraint (tree lhs, enum tree_code op, tree rhs, { bool sat = add_constraint (lhs, op, rhs, ctxt); if (!sat && out) - *out = make_unique <rejected_op_constraint> (*this, lhs, op, rhs); + *out = std::make_unique <rejected_op_constraint> (*this, lhs, op, rhs); return sat; } @@ -6144,7 +6155,7 @@ apply_constraints_for_gswitch (const switch_cfg_superedge &edge, && !ctxt->possibly_tainted_p (index_sval)) { if (out) - *out = make_unique <rejected_default_case> (*this); + *out = std::make_unique <rejected_default_case> (*this); return false; } @@ -6153,7 +6164,8 @@ apply_constraints_for_gswitch (const switch_cfg_superedge &edge, = ranges_mgr->get_or_create_ranges_for_switch (&edge, switch_stmt); bool sat = m_constraints->add_bounded_ranges (index_sval, all_cases_ranges); if (!sat && out) - *out = make_unique <rejected_ranges_constraint> (*this, index, all_cases_ranges); + *out = std::make_unique <rejected_ranges_constraint> + (*this, index, all_cases_ranges); if (sat && ctxt && !all_cases_ranges->empty_p ()) ctxt->on_bounded_ranges (*index_sval, *all_cases_ranges); return sat; @@ -6370,7 +6382,7 @@ public: {} std::unique_ptr<stmt_finder> clone () const override { - return ::make_unique<my_finder> (m_call_stmt, m_caller_frame); + return std::make_unique<my_finder> (m_call_stmt, m_caller_frame); } const gimple *find_stmt (const exploded_path &) override { @@ -6813,7 +6825,7 @@ region_model::check_dynamic_size_for_floats (const svalue *size_in_bytes, if (const svalue *float_sval = v.get_svalue_to_report ()) { tree diag_arg = get_representative_tree (float_sval); - ctxt->warn (make_unique<float_as_size_arg> (diag_arg)); + ctxt->warn (std::make_unique<float_as_size_arg> (diag_arg)); } } @@ -7159,8 +7171,7 @@ private: tree type = m_copied_sval->get_type (); if (type && TREE_CODE (type) == RECORD_TYPE) { - // (std::make_unique is C++14) - layout = std::unique_ptr<record_layout> (new record_layout (type)); + layout = std::make_unique<record_layout> (type); if (0) layout->dump (); @@ -7385,9 +7396,10 @@ region_model::maybe_complain_about_infoleak (const region *dst_reg, { /* Check for exposure. */ if (contains_uninit_p (copied_sval)) - ctxt->warn (make_unique<exposure_through_uninit_copy> (src_reg, - dst_reg, - copied_sval)); + ctxt->warn + (std::make_unique<exposure_through_uninit_copy> (src_reg, + dst_reg, + copied_sval)); } /* Set errno to a positive symbolic int, as if some error has occurred. */ diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index bfbcf2d..4e56cd5 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -27,7 +27,6 @@ along with GCC; see the file COPYING3. If not see #include "digraph.h" #include "sbitmap.h" #include "fold-const.h" -#include "make-unique.h" #include "analyzer/analyzer-logging.h" #include "analyzer/supergraph.h" @@ -1019,7 +1018,7 @@ std::unique_ptr<json::value> region::to_json () const { label_text desc = get_desc (true); - auto reg_js = ::make_unique<json::string> (desc.get ()); + auto reg_js = std::make_unique<json::string> (desc.get ()); return reg_js; } diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc index dd9ae93..cee8d2d 100644 --- a/gcc/analyzer/sm-fd.cc +++ b/gcc/analyzer/sm-fd.cc @@ -1438,7 +1438,7 @@ fd_state_machine::check_for_fd_attrs ( { sm_ctxt.warn (node, stmt, arg, - make_unique<fd_use_after_close> + std::make_unique<fd_use_after_close> (*this, diag_arg, fndecl, attr_name, arg_idx)); @@ -1450,7 +1450,7 @@ fd_state_machine::check_for_fd_attrs ( if (!is_constant_fd_p (state)) { sm_ctxt.warn (node, stmt, arg, - make_unique<fd_use_without_check> + std::make_unique<fd_use_without_check> (*this, diag_arg, fndecl, attr_name, arg_idx)); @@ -1466,13 +1466,13 @@ fd_state_machine::check_for_fd_attrs ( if (is_writeonly_fd_p (state)) { - sm_ctxt.warn ( - node, stmt, arg, - make_unique<fd_access_mode_mismatch> (*this, diag_arg, - DIRS_WRITE, - fndecl, - attr_name, - arg_idx)); + sm_ctxt.warn + (node, stmt, arg, + std::make_unique<fd_access_mode_mismatch> (*this, diag_arg, + DIRS_WRITE, + fndecl, + attr_name, + arg_idx)); } break; @@ -1480,13 +1480,13 @@ fd_state_machine::check_for_fd_attrs ( if (is_readonly_fd_p (state)) { - sm_ctxt.warn ( - node, stmt, arg, - make_unique<fd_access_mode_mismatch> (*this, diag_arg, - DIRS_READ, - fndecl, - attr_name, - arg_idx)); + sm_ctxt.warn + (node, stmt, arg, + std::make_unique<fd_access_mode_mismatch> (*this, diag_arg, + DIRS_READ, + fndecl, + attr_name, + arg_idx)); } break; @@ -1528,7 +1528,7 @@ fd_state_machine::on_open (sm_context &sm_ctxt, const supernode *node, else { sm_ctxt.warn (node, stmt, NULL_TREE, - make_unique<fd_leak> (*this, NULL_TREE)); + std::make_unique<fd_leak> (*this, NULL_TREE)); } } @@ -1541,7 +1541,7 @@ fd_state_machine::on_creat (sm_context &sm_ctxt, const supernode *node, sm_ctxt.on_transition (node, stmt, lhs, m_start, m_unchecked_write_only); else sm_ctxt.warn (node, stmt, NULL_TREE, - make_unique<fd_leak> (*this, NULL_TREE)); + std::make_unique<fd_leak> (*this, NULL_TREE)); } void @@ -1587,8 +1587,8 @@ fd_state_machine::check_for_dup (sm_context &sm_ctxt, const supernode *node, { sm_ctxt.warn ( node, stmt, arg_2, - make_unique<fd_use_without_check> (*this, diag_arg_2, - callee_fndecl)); + std::make_unique<fd_use_without_check> (*this, diag_arg_2, + callee_fndecl)); return; } /* dup2 returns value of its second argument on success.But, the @@ -1635,7 +1635,7 @@ fd_state_machine::on_close (sm_context &sm_ctxt, const supernode *node, if (is_closed_fd_p (state)) { sm_ctxt.warn (node, stmt, arg, - make_unique<fd_double_close> (*this, diag_arg)); + std::make_unique<fd_double_close> (*this, diag_arg)); sm_ctxt.set_next_state (stmt, arg, m_stop); } } @@ -1667,8 +1667,8 @@ fd_state_machine::check_for_open_fd ( if (is_closed_fd_p (state)) { sm_ctxt.warn (node, stmt, arg, - make_unique<fd_use_after_close> (*this, diag_arg, - callee_fndecl)); + std::make_unique<fd_use_after_close> (*this, diag_arg, + callee_fndecl)); } else @@ -1679,10 +1679,10 @@ fd_state_machine::check_for_open_fd ( /* Complain about fncall on socket in wrong phase. */ sm_ctxt.warn (node, stmt, arg, - make_unique<fd_phase_mismatch> (*this, diag_arg, - callee_fndecl, - state, - EXPECTED_PHASE_CAN_TRANSFER)); + std::make_unique<fd_phase_mismatch> (*this, diag_arg, + callee_fndecl, + state, + EXPECTED_PHASE_CAN_TRANSFER)); else if (!(is_valid_fd_p (state) || state == m_new_datagram_socket || state == m_bound_unknown_socket @@ -1693,8 +1693,8 @@ fd_state_machine::check_for_open_fd ( if (!is_constant_fd_p (state)) sm_ctxt.warn ( node, stmt, arg, - make_unique<fd_use_without_check> (*this, diag_arg, - callee_fndecl)); + std::make_unique<fd_use_without_check> (*this, diag_arg, + callee_fndecl)); } switch (callee_fndecl_dir) { @@ -1705,8 +1705,8 @@ fd_state_machine::check_for_open_fd ( { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<fd_access_mode_mismatch> ( - *this, diag_arg, DIRS_WRITE, callee_fndecl)); + std::make_unique<fd_access_mode_mismatch> + (*this, diag_arg, DIRS_WRITE, callee_fndecl)); } break; @@ -1716,8 +1716,8 @@ fd_state_machine::check_for_open_fd ( { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<fd_access_mode_mismatch> ( - *this, diag_arg, DIRS_READ, callee_fndecl)); + std::make_unique<fd_access_mode_mismatch> + (*this, diag_arg, DIRS_READ, callee_fndecl)); } break; } @@ -1792,7 +1792,7 @@ fd_state_machine::on_socket (const call_details &cd, } else sm_ctxt.warn (node, &call, NULL_TREE, - make_unique<fd_leak> (*this, NULL_TREE)); + std::make_unique<fd_leak> (*this, NULL_TREE)); } else { @@ -1829,8 +1829,8 @@ fd_state_machine::check_for_socket_fd (const call_details &cd, tree diag_arg = sm_ctxt.get_diagnostic_tree (fd_sval); sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_use_after_close> (*this, diag_arg, - cd.get_fndecl_for_call ())); + std::make_unique<fd_use_after_close> (*this, diag_arg, + cd.get_fndecl_for_call ())); if (complained) *complained = true; if (successful) @@ -1842,10 +1842,10 @@ fd_state_machine::check_for_socket_fd (const call_details &cd, tree diag_arg = sm_ctxt.get_diagnostic_tree (fd_sval); sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_type_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - EXPECTED_TYPE_SOCKET)); + std::make_unique<fd_type_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + EXPECTED_TYPE_SOCKET)); if (complained) *complained = true; if (successful) @@ -1856,8 +1856,8 @@ fd_state_machine::check_for_socket_fd (const call_details &cd, tree diag_arg = sm_ctxt.get_diagnostic_tree (fd_sval); sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_use_without_check> (*this, diag_arg, - cd.get_fndecl_for_call ())); + std::make_unique<fd_use_without_check> (*this, diag_arg, + cd.get_fndecl_for_call ())); if (complained) *complained = true; if (successful) @@ -1919,10 +1919,10 @@ fd_state_machine::check_for_new_socket_fd (const call_details &cd, tree diag_arg = sm_ctxt.get_diagnostic_tree (fd_sval); sm_ctxt.warn (node, &cd.get_call_stmt (), fd_sval, - make_unique<fd_phase_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - expected_phase)); + std::make_unique<fd_phase_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + expected_phase)); if (successful) return false; } @@ -2029,17 +2029,17 @@ fd_state_machine::on_listen (const call_details &cd, if (is_stream_socket_fd_p (old_state)) sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_phase_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - EXPECTED_PHASE_CAN_LISTEN)); + std::make_unique<fd_phase_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + EXPECTED_PHASE_CAN_LISTEN)); else sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_type_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - EXPECTED_TYPE_STREAM_SOCKET)); + std::make_unique<fd_type_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + EXPECTED_TYPE_STREAM_SOCKET)); if (successful) return false; } @@ -2150,17 +2150,17 @@ fd_state_machine::on_accept (const call_details &cd, if (is_stream_socket_fd_p (old_state)) sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_phase_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - EXPECTED_PHASE_CAN_ACCEPT)); + std::make_unique<fd_phase_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + EXPECTED_PHASE_CAN_ACCEPT)); else sm_ctxt.warn (node, &call, fd_sval, - make_unique<fd_type_mismatch> (*this, diag_arg, - cd.get_fndecl_for_call (), - old_state, - EXPECTED_TYPE_STREAM_SOCKET)); + std::make_unique<fd_type_mismatch> (*this, diag_arg, + cd.get_fndecl_for_call (), + old_state, + EXPECTED_TYPE_STREAM_SOCKET)); if (successful) return false; } @@ -2185,7 +2185,7 @@ fd_state_machine::on_accept (const call_details &cd, } else sm_ctxt.warn (node, &call, NULL_TREE, - make_unique<fd_leak> (*this, NULL_TREE)); + std::make_unique<fd_leak> (*this, NULL_TREE)); } else { @@ -2323,7 +2323,7 @@ fd_state_machine::can_purge_p (state_t s) const std::unique_ptr<pending_diagnostic> fd_state_machine::on_leak (tree var) const { - return make_unique<fd_leak> (*this, var); + return std::make_unique<fd_leak> (*this, var); } } // namespace @@ -2415,8 +2415,10 @@ public: { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_socket> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_socket> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_socket> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_socket> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2467,8 +2469,10 @@ public: { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_bind> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_bind> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_bind> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_bind> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2519,8 +2523,10 @@ class kf_listen : public known_function { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_listen> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_listen> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_listen> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_listen> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2573,8 +2579,10 @@ class kf_accept : public known_function { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_accept> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_accept> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_accept> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_accept> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2627,8 +2635,10 @@ public: { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_connect> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_connect> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_connect> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_connect> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2705,8 +2715,10 @@ public: { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_isatty> (cd, false)); - cd.get_ctxt ()->bifurcate (make_unique<outcome_of_isatty> (cd, true)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_isatty> (cd, false)); + cd.get_ctxt ()->bifurcate + (std::make_unique<outcome_of_isatty> (cd, true)); cd.get_ctxt ()->terminate_path (); } } @@ -2788,8 +2800,10 @@ public: { if (cd.get_ctxt ()) { - cd.get_ctxt ()->bifurcate (make_unique<failure> (cd)); - cd.get_ctxt ()->bifurcate (make_unique<success> (cd)); + cd.get_ctxt ()->bifurcate + (std::make_unique<failure> (cd)); + cd.get_ctxt ()->bifurcate + (std::make_unique<success> (cd)); cd.get_ctxt ()->terminate_path (); } } @@ -2837,15 +2851,15 @@ public: void register_known_fd_functions (known_function_manager &kfm) { - kfm.add ("accept", make_unique<kf_accept> ()); - kfm.add ("bind", make_unique<kf_bind> ()); - kfm.add ("connect", make_unique<kf_connect> ()); - kfm.add ("isatty", make_unique<kf_isatty> ()); - kfm.add ("listen", make_unique<kf_listen> ()); - kfm.add ("pipe", make_unique<kf_pipe> (1)); - kfm.add ("pipe2", make_unique<kf_pipe> (2)); - kfm.add ("read", make_unique<kf_read> ()); - kfm.add ("socket", make_unique<kf_socket> ()); + kfm.add ("accept", std::make_unique<kf_accept> ()); + kfm.add ("bind", std::make_unique<kf_bind> ()); + kfm.add ("connect", std::make_unique<kf_connect> ()); + kfm.add ("isatty", std::make_unique<kf_isatty> ()); + kfm.add ("listen", std::make_unique<kf_listen> ()); + kfm.add ("pipe", std::make_unique<kf_pipe> (1)); + kfm.add ("pipe2", std::make_unique<kf_pipe> (2)); + kfm.add ("read", std::make_unique<kf_read> ()); + kfm.add ("socket", std::make_unique<kf_socket> ()); } } // namespace ana diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc index 319ac01..d7dbe2f 100644 --- a/gcc/analyzer/sm-file.cc +++ b/gcc/analyzer/sm-file.cc @@ -423,7 +423,8 @@ fileptr_state_machine::on_stmt (sm_context &sm_ctxt, { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<double_fclose> (*this, diag_arg)); + std::make_unique<double_fclose> (*this, + diag_arg)); sm_ctxt.set_next_state (stmt, arg, m_stop); } return true; @@ -493,7 +494,7 @@ fileptr_state_machine::can_purge_p (state_t s) const std::unique_ptr<pending_diagnostic> fileptr_state_machine::on_leak (tree var) const { - return make_unique<file_leak> (*this, var); + return std::make_unique<file_leak> (*this, var); } } // anonymous namespace @@ -645,40 +646,40 @@ public: void register_known_file_functions (known_function_manager &kfm) { - kfm.add (BUILT_IN_FPRINTF, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FPRINTF_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FPUTC, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FPUTC_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FPUTS, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FPUTS_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FWRITE, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_FWRITE_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PRINTF, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PRINTF_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTC, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTCHAR, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTCHAR_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTC_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTS, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_PUTS_UNLOCKED, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_VFPRINTF, make_unique<kf_stdio_output_fn> ()); - kfm.add (BUILT_IN_VPRINTF, make_unique<kf_stdio_output_fn> ()); - - kfm.add ("ferror", make_unique<kf_ferror> ()); - kfm.add ("fgets", make_unique<kf_fgets> ()); - kfm.add ("fgets_unlocked", make_unique<kf_fgets> ()); // non-standard - kfm.add ("fileno", make_unique<kf_fileno> ()); - kfm.add ("fread", make_unique<kf_fread> ()); - kfm.add ("getc", make_unique<kf_getc> ()); - kfm.add ("getchar", make_unique<kf_getchar> ()); + kfm.add (BUILT_IN_FPRINTF, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FPRINTF_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FPUTC, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FPUTC_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FPUTS, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FPUTS_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FWRITE, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_FWRITE_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PRINTF, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PRINTF_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTC, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTCHAR, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTCHAR_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTC_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTS, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_PUTS_UNLOCKED, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_VFPRINTF, std::make_unique<kf_stdio_output_fn> ()); + kfm.add (BUILT_IN_VPRINTF, std::make_unique<kf_stdio_output_fn> ()); + + kfm.add ("ferror", std::make_unique<kf_ferror> ()); + kfm.add ("fgets", std::make_unique<kf_fgets> ()); + kfm.add ("fgets_unlocked", std::make_unique<kf_fgets> ()); // non-standard + kfm.add ("fileno", std::make_unique<kf_fileno> ()); + kfm.add ("fread", std::make_unique<kf_fread> ()); + kfm.add ("getc", std::make_unique<kf_getc> ()); + kfm.add ("getchar", std::make_unique<kf_getchar> ()); /* Some C++ implementations use the std:: copies of these functions from <cstdio> for <stdio.h>, so we must match against these too. */ - kfm.add_std_ns ("ferror", make_unique<kf_ferror> ()); - kfm.add_std_ns ("fgets", make_unique<kf_fgets> ()); - kfm.add_std_ns ("fread", make_unique<kf_fread> ()); - kfm.add_std_ns ("getc", make_unique<kf_getc> ()); - kfm.add_std_ns ("getchar", make_unique<kf_getchar> ()); + kfm.add_std_ns ("ferror", std::make_unique<kf_ferror> ()); + kfm.add_std_ns ("fgets", std::make_unique<kf_fgets> ()); + kfm.add_std_ns ("fread", std::make_unique<kf_fread> ()); + kfm.add_std_ns ("getc", std::make_unique<kf_getc> ()); + kfm.add_std_ns ("getchar", std::make_unique<kf_getchar> ()); } #if CHECKING_P diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index ad7974e..0186268 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -2018,9 +2018,10 @@ malloc_state_machine::handle_nonnull (sm_context &sm_ctxt, if (unchecked_p (state)) { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); - sm_ctxt.warn (node, stmt, arg, - make_unique<possible_null_arg> (*this, diag_arg, fndecl, - i)); + sm_ctxt.warn + (node, stmt, arg, + std::make_unique<possible_null_arg> (*this, diag_arg, fndecl, + i)); const allocation_state *astate = as_a_allocation_state (state); sm_ctxt.set_next_state (stmt, arg, astate->get_nonnull ()); @@ -2029,7 +2030,7 @@ malloc_state_machine::handle_nonnull (sm_context &sm_ctxt, { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<null_arg> (*this, diag_arg, fndecl, i)); + std::make_unique<null_arg> (*this, diag_arg, fndecl, i)); sm_ctxt.set_next_state (stmt, arg, m_stop); } else if (state == m_start) @@ -2251,8 +2252,8 @@ malloc_state_machine::on_stmt (sm_context &sm_ctxt, { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<possible_null_deref> (*this, - diag_arg)); + std::make_unique<possible_null_deref> (*this, + diag_arg)); const allocation_state *astate = as_a_allocation_state (state); sm_ctxt.set_next_state (stmt, arg, astate->get_nonnull ()); } @@ -2260,7 +2261,7 @@ malloc_state_machine::on_stmt (sm_context &sm_ctxt, { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<null_deref> (*this, diag_arg)); + std::make_unique<null_deref> (*this, diag_arg)); sm_ctxt.set_next_state (stmt, arg, m_stop); } else if (freed_p (state)) @@ -2268,7 +2269,7 @@ malloc_state_machine::on_stmt (sm_context &sm_ctxt, tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); const allocation_state *astate = as_a_allocation_state (state); sm_ctxt.warn (node, stmt, arg, - make_unique<use_after_free> + std::make_unique<use_after_free> (*this, diag_arg, astate->m_deallocator)); sm_ctxt.set_next_state (stmt, arg, m_stop); } @@ -2330,7 +2331,7 @@ maybe_complain_about_deref_before_check (sm_context &sm_ctxt, if (diag_ptr) sm_ctxt.warn (node, stmt, ptr, - make_unique<deref_before_check> (*this, diag_ptr)); + std::make_unique<deref_before_check> (*this, diag_ptr)); sm_ctxt.set_next_state (stmt, ptr, m_stop); } @@ -2378,7 +2379,7 @@ malloc_state_machine::handle_free_of_non_heap (sm_context &sm_ctxt, freed_reg = old_model->deref_rvalue (ptr_sval, arg, NULL); } sm_ctxt.warn (node, &call, arg, - make_unique<free_of_non_heap> + std::make_unique<free_of_non_heap> (*this, diag_arg, freed_reg, d->m_name)); sm_ctxt.set_next_state (&call, arg, m_stop); } @@ -2408,7 +2409,7 @@ malloc_state_machine::on_deallocator_call (sm_context &sm_ctxt, /* Wrong allocator. */ tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, &call, arg, - make_unique<mismatching_deallocation> + std::make_unique<mismatching_deallocation> (*this, diag_arg, astate->m_deallocators, d)); @@ -2423,7 +2424,7 @@ malloc_state_machine::on_deallocator_call (sm_context &sm_ctxt, /* freed -> stop, with warning. */ tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, &call, arg, - make_unique<double_free> (*this, diag_arg, d->m_name)); + std::make_unique<double_free> (*this, diag_arg, d->m_name)); sm_ctxt.set_next_state (&call, arg, m_stop); } else if (state == m_non_heap) @@ -2462,7 +2463,7 @@ malloc_state_machine::on_realloc_call (sm_context &sm_ctxt, /* Wrong allocator. */ tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, &call, arg, - make_unique<mismatching_deallocation> + std::make_unique<mismatching_deallocation> (*this, diag_arg, astate->m_deallocators, d)); sm_ctxt.set_next_state (&call, arg, m_stop); @@ -2475,7 +2476,7 @@ malloc_state_machine::on_realloc_call (sm_context &sm_ctxt, /* freed -> stop, with warning. */ tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, &call, arg, - make_unique<double_free> (*this, diag_arg, "free")); + std::make_unique<double_free> (*this, diag_arg, "free")); sm_ctxt.set_next_state (&call, arg, m_stop); if (path_context *path_ctxt = sm_ctxt.get_path_context ()) path_ctxt->terminate_path (); @@ -2585,7 +2586,7 @@ malloc_state_machine::can_purge_p (state_t s) const std::unique_ptr<pending_diagnostic> malloc_state_machine::on_leak (tree var) const { - return make_unique<malloc_leak> (*this, var); + return std::make_unique<malloc_leak> (*this, var); } /* Implementation of state_machine::reset_when_passed_to_unknown_fn_p vfunc diff --git a/gcc/analyzer/sm-pattern-test.cc b/gcc/analyzer/sm-pattern-test.cc index f24e8df..f05ffe0 100644 --- a/gcc/analyzer/sm-pattern-test.cc +++ b/gcc/analyzer/sm-pattern-test.cc @@ -132,7 +132,7 @@ pattern_test_state_machine::on_condition (sm_context &sm_ctxt, if (tree lhs_expr = sm_ctxt.get_diagnostic_tree (lhs)) { sm_ctxt.warn (node, stmt, lhs_expr, - make_unique<pattern_match> (lhs_expr, op, rhs_cst)); + std::make_unique<pattern_match> (lhs_expr, op, rhs_cst)); } } diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc index 385573b..7bd5ef6 100644 --- a/gcc/analyzer/sm-sensitive.cc +++ b/gcc/analyzer/sm-sensitive.cc @@ -187,8 +187,8 @@ sensitive_state_machine::warn_for_any_exposure (sm_context &sm_ctxt, { tree diag_arg = sm_ctxt.get_diagnostic_tree (arg); sm_ctxt.warn (node, stmt, arg, - make_unique<exposure_through_output_file> (*this, - diag_arg)); + std::make_unique<exposure_through_output_file> (*this, + diag_arg)); } } diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc index 2521c7c..bbd7d70 100644 --- a/gcc/analyzer/sm-signal.cc +++ b/gcc/analyzer/sm-signal.cc @@ -225,10 +225,10 @@ public: const final override { emission_path->add_event - (make_unique<precanned_custom_event> - (event_loc_info (UNKNOWN_LOCATION, NULL_TREE, 0), - "later on," - " when the signal is delivered to the process")); + (std::make_unique<precanned_custom_event> + (event_loc_info (UNKNOWN_LOCATION, NULL_TREE, 0), + "later on," + " when the signal is delivered to the process")); } }; @@ -271,7 +271,7 @@ public: if (dst_enode) eg->add_edge (src_enode, dst_enode, NULL, /*state_change (),*/ true, /* assume does work */ - make_unique<signal_delivery_edge_info_t> ()); + std::make_unique<signal_delivery_edge_info_t> ()); } const signal_state_machine &m_sm; @@ -352,7 +352,7 @@ signal_state_machine::on_stmt (sm_context &sm_ctxt, if (signal_unsafe_p (callee_fndecl)) if (sm_ctxt.get_global_state () == m_in_signal_handler) sm_ctxt.warn (node, stmt, NULL_TREE, - make_unique<signal_unsafe_call> + std::make_unique<signal_unsafe_call> (*this, *call, callee_fndecl)); } diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index 21ce68e..e782081 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -1113,8 +1113,8 @@ taint_state_machine::on_stmt (sm_context &sm_ctxt, && sm_ctxt.get_global_state () == m_tainted_control_flow) { sm_ctxt.warn (node, call, NULL_TREE, - make_unique<tainted_assertion> (*this, NULL_TREE, - callee_fndecl)); + std::make_unique<tainted_assertion> (*this, NULL_TREE, + callee_fndecl)); } } // TODO: ...etc; many other sources of untrusted data @@ -1464,7 +1464,7 @@ taint_state_machine::check_for_tainted_size_arg (sm_context &sm_ctxt, TREE_STRING_POINTER (access->to_external_string ()); tree diag_size = sm_ctxt.get_diagnostic_tree (size_arg); sm_ctxt.warn (node, &call, size_arg, - make_unique<tainted_access_attrib_size> + std::make_unique<tainted_access_attrib_size> (*this, diag_size, b, callee_fndecl, access->sizarg, @@ -1508,8 +1508,9 @@ taint_state_machine::check_for_tainted_divisor (sm_context &sm_ctxt, return; tree diag_divisor = sm_ctxt.get_diagnostic_tree (divisor_expr); - sm_ctxt.warn (node, assign, divisor_expr, - make_unique <tainted_divisor> (*this, diag_divisor, b)); + sm_ctxt.warn + (node, assign, divisor_expr, + std::make_unique <tainted_divisor> (*this, diag_divisor, b)); sm_ctxt.set_next_state (assign, divisor_sval, m_stop); } } @@ -1672,8 +1673,8 @@ region_model::check_region_for_taint (const region *reg, if (index_can_be_out_of_bounds_p (element_reg)) { tree arg = get_representative_tree (index); - ctxt->warn (make_unique<tainted_array_index> (taint_sm, - arg, b)); + ctxt->warn (std::make_unique<tainted_array_index> (taint_sm, + arg, b)); } else if (ctxt->get_logger ()) ctxt->get_logger ()->log ("rejecting tainted_array_index as" @@ -1699,8 +1700,8 @@ region_model::check_region_for_taint (const region *reg, if (taint_sm.get_taint (state, effective_type, &b)) { tree arg = get_representative_tree (offset); - ctxt->warn (make_unique<tainted_offset> (taint_sm, arg, b, - offset)); + ctxt->warn (std::make_unique<tainted_offset> (taint_sm, arg, b, + offset)); } } break; @@ -1717,7 +1718,7 @@ region_model::check_region_for_taint (const region *reg, if (taint_sm.get_taint (state, size_sval->get_type (), &b)) { tree arg = get_representative_tree (size_sval); - ctxt->warn (make_unique<tainted_size> (taint_sm, arg, b)); + ctxt->warn (std::make_unique<tainted_size> (taint_sm, arg, b)); } } break; @@ -1763,7 +1764,7 @@ region_model::check_dynamic_size_for_taint (enum memory_space mem_space, if (taint_sm.get_taint (state, size_in_bytes->get_type (), &b)) { tree arg = get_representative_tree (size_in_bytes); - ctxt->warn (make_unique<tainted_allocation_size> + ctxt->warn (std::make_unique<tainted_allocation_size> (taint_sm, arg, size_in_bytes, b, mem_space)); } } diff --git a/gcc/analyzer/sm.cc b/gcc/analyzer/sm.cc index 4328e3c..0abbdd6 100644 --- a/gcc/analyzer/sm.cc +++ b/gcc/analyzer/sm.cc @@ -72,7 +72,7 @@ state_machine::state::to_json () const pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; dump_to_pp (&pp); - return ::make_unique<json::string> (pp_formatted_text (&pp)); + return std::make_unique<json::string> (pp_formatted_text (&pp)); } /* class state_machine. */ @@ -143,11 +143,11 @@ state_machine::dump_to_pp (pretty_printer *pp) const std::unique_ptr<json::object> state_machine::to_json () const { - auto sm_obj = ::make_unique<json::object> (); + auto sm_obj = std::make_unique<json::object> (); sm_obj->set_string ("name", m_name); { - auto states_arr = ::make_unique<json::array> (); + auto states_arr = std::make_unique<json::array> (); unsigned i; state *s; FOR_EACH_VEC_ELT (m_states, i, s) diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index 6716aaf..e6723c7 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -213,7 +213,7 @@ bit_range::dump () const std::unique_ptr<json::object> bit_range::to_json () const { - auto obj = ::make_unique<json::object> (); + auto obj = std::make_unique<json::object> (); obj->set ("start_bit_offset", bit_offset_to_json (m_start_bit_offset)); obj->set ("size_in_bits", @@ -487,7 +487,7 @@ byte_range::dump () const std::unique_ptr<json::object> byte_range::to_json () const { - auto obj = ::make_unique<json::object> (); + auto obj = std::make_unique<json::object> (); obj->set ("start_byte_offset", byte_offset_to_json (m_start_byte_offset)); obj->set ("size_in_bytes", @@ -752,7 +752,7 @@ binding_map::dump (bool simple) const std::unique_ptr<json::object> binding_map::to_json () const { - auto map_obj = ::make_unique<json::object> (); + auto map_obj = std::make_unique<json::object> (); auto_vec <const binding_key *> binding_keys; for (map_t::iterator iter = m_map.begin (); @@ -1434,7 +1434,7 @@ binding_cluster::validate () const std::unique_ptr<json::object> binding_cluster::to_json () const { - auto cluster_obj = ::make_unique<json::object> (); + auto cluster_obj = std::make_unique<json::object> (); cluster_obj->set_bool ("escaped", m_escaped); cluster_obj->set_bool ("touched", m_touched); @@ -2651,7 +2651,7 @@ store::validate () const std::unique_ptr<json::object> store::to_json () const { - auto store_obj = ::make_unique<json::object> (); + auto store_obj = std::make_unique<json::object> (); /* Sort into some deterministic order. */ auto_vec<const region *> base_regions; @@ -2674,7 +2674,7 @@ store::to_json () const { gcc_assert (parent_reg); - auto clusters_in_parent_reg_obj = ::make_unique<json::object> (); + auto clusters_in_parent_reg_obj = std::make_unique<json::object> (); const region *base_reg; unsigned j; diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index 67c676f..f4823c6 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -444,11 +444,11 @@ supergraph::dump_dot (const char *path, const dump_args_t &dump_args) const std::unique_ptr<json::object> supergraph::to_json () const { - auto sgraph_obj = ::make_unique<json::object> (); + auto sgraph_obj = std::make_unique<json::object> (); /* Nodes. */ { - auto nodes_arr = ::make_unique<json::array> (); + auto nodes_arr = std::make_unique<json::array> (); unsigned i; supernode *n; FOR_EACH_VEC_ELT (m_nodes, i, n) @@ -458,7 +458,7 @@ supergraph::to_json () const /* Edges. */ { - auto edges_arr = ::make_unique<json::array> (); + auto edges_arr = std::make_unique<json::array> (); unsigned i; superedge *n; FOR_EACH_VEC_ELT (m_edges, i, n) @@ -699,7 +699,7 @@ supernode::dump_dot_id (pretty_printer *pp) const std::unique_ptr<json::object> supernode::to_json () const { - auto snode_obj = ::make_unique<json::object> (); + auto snode_obj = std::make_unique<json::object> (); snode_obj->set_integer ("idx", m_index); snode_obj->set_integer ("bb_idx", m_bb->index); @@ -716,7 +716,7 @@ supernode::to_json () const /* Phi nodes. */ { - auto phi_arr = ::make_unique<json::array> (); + auto phi_arr = std::make_unique<json::array> (); for (gphi_iterator gpi = const_cast<supernode *> (this)->start_phis (); !gsi_end_p (gpi); gsi_next (&gpi)) { @@ -731,7 +731,7 @@ supernode::to_json () const /* Statements. */ { - auto stmt_arr = ::make_unique<json::array> (); + auto stmt_arr = std::make_unique<json::array> (); int i; gimple *stmt; FOR_EACH_VEC_ELT (m_stmts, i, stmt) @@ -962,7 +962,7 @@ superedge::dump_dot (graphviz_out *gv, const dump_args_t &) const std::unique_ptr<json::object> superedge::to_json () const { - auto sedge_obj = ::make_unique<json::object> (); + auto sedge_obj = std::make_unique<json::object> (); sedge_obj->set_string ("kind", edge_kind_to_string (m_kind)); sedge_obj->set_integer ("src_idx", m_src->m_index); sedge_obj->set_integer ("dst_idx", m_dest->m_index); diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index ed51115..513d9cc 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -25,7 +25,6 @@ along with GCC; see the file COPYING3. If not see #include "fold-const.h" #include "diagnostic.h" #include "tree-diagnostic.h" -#include "make-unique.h" #include "text-art/dump.h" @@ -36,7 +35,6 @@ along with GCC; see the file COPYING3. If not see #include "analyzer/svalue.h" #include "analyzer/region-model.h" - #if ENABLE_ANALYZER namespace ana { @@ -92,7 +90,7 @@ std::unique_ptr<json::value> svalue::to_json () const { label_text desc = get_desc (true); - auto sval_js = ::make_unique<json::string> (desc.get ()); + auto sval_js = std::make_unique<json::string> (desc.get ()); return sval_js; } diff --git a/gcc/analyzer/varargs.cc b/gcc/analyzer/varargs.cc index 55730a3..6ea0d29 100644 --- a/gcc/analyzer/varargs.cc +++ b/gcc/analyzer/varargs.cc @@ -556,7 +556,7 @@ va_list_state_machine::check_for_ended_va_list (sm_context &sm_ctxt, { if (sm_ctxt.get_state (&call, arg) == m_ended) sm_ctxt.warn (node, &call, arg, - make_unique<va_list_use_after_va_end> + std::make_unique<va_list_use_after_va_end> (*this, arg, NULL_TREE, usage_fnname)); } @@ -635,7 +635,7 @@ va_list_state_machine::on_va_end (sm_context &sm_ctxt, std::unique_ptr<pending_diagnostic> va_list_state_machine::on_leak (tree var) const { - return make_unique<va_list_leak> (*this, nullptr, var); + return std::make_unique<va_list_leak> (*this, nullptr, var); } } // anonymous namespace @@ -814,7 +814,7 @@ public: = get_num_variadic_arguments (dst_node->get_function ()->decl, call_stmt); emission_path->add_event - (make_unique<va_arg_call_event> + (std::make_unique<va_arg_call_event> (eedge, event_loc_info (last_stmt ? last_stmt->location : UNKNOWN_LOCATION, src_point.get_fndecl (), @@ -1070,7 +1070,7 @@ kf_va_arg::impl_call_pre (const call_details &cd) const else { if (ctxt) - ctxt->warn (make_unique <va_arg_type_mismatch> + ctxt->warn (std::make_unique <va_arg_type_mismatch> (va_list_tree, arg_reg, lhs_type, @@ -1081,8 +1081,9 @@ kf_va_arg::impl_call_pre (const call_details &cd) const else { if (ctxt) - ctxt->warn (make_unique <va_list_exhausted> (va_list_tree, - arg_reg)); + ctxt->warn + (std::make_unique <va_list_exhausted> (va_list_tree, + arg_reg)); saw_problem = true; } } @@ -1131,10 +1132,10 @@ public: void register_varargs_builtins (known_function_manager &kfm) { - kfm.add (BUILT_IN_VA_START, make_unique<kf_va_start> ()); - kfm.add (BUILT_IN_VA_COPY, make_unique<kf_va_copy> ()); - kfm.add (IFN_VA_ARG, make_unique<kf_va_arg> ()); - kfm.add (BUILT_IN_VA_END, make_unique<kf_va_end> ()); + kfm.add (BUILT_IN_VA_START, std::make_unique<kf_va_start> ()); + kfm.add (BUILT_IN_VA_COPY, std::make_unique<kf_va_copy> ()); + kfm.add (IFN_VA_ARG, std::make_unique<kf_va_arg> ()); + kfm.add (BUILT_IN_VA_END, std::make_unique<kf_va_end> ()); } } // namespace ana |