Daily bump.
[official-gcc.git] / gcc / analyzer / ChangeLog
blobf6bf272628443624826b737bf95887d47a835332
1 2021-11-12  David Malcolm  <dmalcolm@redhat.com>
3         * engine.cc (exploded_node::on_stmt_pre): Return when handling
4         "__analyzer_dump_state".
6 2021-11-11  Richard Biener  <rguenther@suse.de>
8         * supergraph.cc: Include bitmap.h.
10 2021-11-04  David Malcolm  <dmalcolm@redhat.com>
12         * program-state.cc (sm_state_map::dump): Use default_tree_printer
13         as format decoder.
15 2021-09-16  Maxim Blinov  <maxim.blinov@embecosm.com>
17         PR bootstrap/102242
18         * engine.cc (INCLUDE_UNIQUE_PTR): Define.
20 2021-09-08  David Malcolm  <dmalcolm@redhat.com>
22         PR analyzer/102225
23         * analyzer.h (compat_types_p): New decl.
24         * constraint-manager.cc
25         (constraint_manager::get_or_add_equiv_class): Guard against NULL
26         type when checking for pointer types.
27         * region-model-impl-calls.cc (region_model::impl_call_realloc):
28         Guard against NULL lhs type/region.  Guard against the size value
29         not being of a compatible type for dynamic extents.
30         * region-model.cc (compat_types_p): Make non-static.
32 2021-08-30  David Malcolm  <dmalcolm@redhat.com>
34         PR analyzer/99260
35         * analyzer.h (class custom_edge_info): New class, adapted from
36         exploded_edge::custom_info_t.  Make member functions const.
37         Make update_model return bool, converting edge param from
38         reference to a pointer, and adding a ctxt param.
39         (class path_context): New class.
40         * call-info.cc: New file.
41         * call-info.h: New file.
42         * engine.cc: Include "analyzer/call-info.h" and <memory>.
43         (impl_region_model_context::impl_region_model_context): Update for
44         new m_path_ctxt field.
45         (impl_region_model_context::bifurcate): New.
46         (impl_region_model_context::terminate_path): New.
47         (impl_region_model_context::get_malloc_map): New.
48         (impl_sm_context::impl_sm_context): Update for new m_path_ctxt
49         field.
50         (impl_sm_context::get_fndecl_for_call): Likewise.
51         (impl_sm_context::set_next_state): Likewise.
52         (impl_sm_context::warn): Likewise.
53         (impl_sm_context::is_zero_assignment): Likewise.
54         (impl_sm_context::get_path_context): New.
55         (impl_sm_context::m_path_ctxt): New.
56         (impl_region_model_context::on_condition): Update for new
57         path_ctxt param.  Handle m_enode_for_diag being NULL.
58         (impl_region_model_context::on_phi): Update for new path_ctxt
59         param.
60         (exploded_node::on_stmt): Add path_ctxt param, updating ctor calls
61         to use it as necessary.  Use it to bail out after sm-handling,
62         if needed.
63         (exploded_node::detect_leaks): Update for new path_ctxt param.
64         (dynamic_call_info_t::update_model): Update for conversion of
65         exploded_edge::custom_info_t to custom_edge_info.
66         (dynamic_call_info_t::add_events_to_path): Likewise.
67         (rewind_info_t::update_model): Likewise.
68         (rewind_info_t::add_events_to_path): Likewise.
69         (exploded_edge::exploded_edge): Likewise.
70         (exploded_graph::add_edge): Likewise.
71         (exploded_graph::maybe_process_run_of_before_supernode_enodes):
72         Update for new path_ctxt param.
73         (class impl_path_context): New.
74         (exploded_graph::process_node): Update for new path_ctxt param.
75         Create an impl_path_context and pass it to exploded_node::on_stmt.
76         Use it to terminate iterating stmts if terminate_path is called
77         on it.  After processing a run of stmts, query path_ctxt to
78         potentially terminate the analysis path, and/or to "bifurcate" the
79         analysis into multiple additional paths.
80         (feasibility_state::maybe_update_for_edge): Update for new
81         update_model ctxt param.
82         * exploded-graph.h
83         (impl_region_model_context::impl_region_model_context): Add
84         path_ctxt param.
85         (impl_region_model_context::bifurcate): New.
86         (impl_region_model_context::terminate_path): New
87         (impl_region_model_context::get_ext_state): New.
88         (impl_region_model_context::get_malloc_map): New.
89         (impl_region_model_context::m_path_ctxt): New field.
90         (exploded_node::on_stmt): Add path_ctxt param.
91         (class exploded_edge::custom_info_t): Move to analyzer.h, renaming
92         to custom_edge_info, and making the changes as noted in analyzer.h
93         above.
94         (exploded_edge::exploded_edge): Update for these changes to
95         exploded_edge::custom_info_t.
96         (exploded_edge::m_custom_info): Likewise.
97         (class dynamic_call_info_t): Likewise.
98         (class rewind_info_t): Likewise.
99         (exploded_graph::add_edge): Likewise.
100         * program-state.cc (program_state::on_edge): Update for new
101         path_ctxt param.
102         (program_state::push_call): Likewise.
103         (program_state::returning_call): Likewise.
104         (program_state::prune_for_point): Likewise.
105         * region-model-impl-calls.cc: Include "analyzer/call-info.h".
106         (call_details::get_fndecl_for_call): New.
107         (region_model::impl_call_realloc): Reimplement.
108         * region-model.cc (region_model::on_call_pre): Move call to
109         impl_call_realloc to...
110         (region_model::on_call_post): ...here.  Consolidate creation
111         of call_details instance.
112         (noop_region_model_context::bifurcate): New.
113         (noop_region_model_context::terminate_path): New.
114         * region-model.h (call_details::get_call_stmt): New.
115         (call_details::get_fndecl_for_call): New.
116         (region_model::on_realloc_with_move): New.
117         (region_model_context::bifurcate): New.
118         (region_model_context::terminate_path): New.
119         (region_model_context::get_ext_state): New.
120         (region_model_context::get_malloc_map): New.
121         (noop_region_model_context::bifurcate): New.
122         (noop_region_model_context::terminate_path): New.
123         (noop_region_model_context::get_ext_state): New.
124         (noop_region_model_context::get_malloc_map): New.
125         * sm-malloc.cc: Include "analyzer/program-state.h".
126         (malloc_state_machine::on_realloc_call): Reimplement.
127         (malloc_state_machine::on_realloc_with_move): New.
128         (region_model::on_realloc_with_move): New.
129         * sm-signal.cc (class signal_delivery_edge_info_t): Update for
130         conversion from exploded_edge::custom_info_t to custom_edge_info.
131         * sm.h (sm_context::get_path_context): New.
132         * svalue.cc (svalue::maybe_get_constant): Call
133         unwrap_any_unmergeable.
135 2021-08-25  Ankur Saini  <arsenic@sourceware.org>
137         PR analyzer/101980
138         * engine.cc (exploded_graph::maybe_create_dynamic_call): Don't create
139         calls if max recursion limit is reached.
141 2021-08-23  David Malcolm  <dmalcolm@redhat.com>
143         * analyzer.h (struct rejected_constraint): Convert to...
144         (class rejected_constraint): ...this.
145         (class bounded_ranges): New forward decl.
146         (class bounded_ranges_manager): New forward decl.
147         * constraint-manager.cc: Include "analyzer/analyzer-logging.h" and
148         "tree-pretty-print.h".
149         (can_plus_one_p): New.
150         (plus_one): New.
151         (can_minus_one_p): New.
152         (minus_one): New.
153         (bounded_range::bounded_range): New.
154         (dump_cst): New.
155         (bounded_range::dump_to_pp): New.
156         (bounded_range::dump): New.
157         (bounded_range::to_json): New.
158         (bounded_range::set_json_attr): New.
159         (bounded_range::contains_p): New.
160         (bounded_range::intersects_p): New.
161         (bounded_range::operator==): New.
162         (bounded_range::cmp): New.
163         (bounded_ranges::bounded_ranges): New.
164         (bounded_ranges::bounded_ranges): New.
165         (bounded_ranges::bounded_ranges): New.
166         (bounded_ranges::canonicalize): New.
167         (bounded_ranges::validate): New.
168         (bounded_ranges::operator==): New.
169         (bounded_ranges::dump_to_pp): New.
170         (bounded_ranges::dump): New.
171         (bounded_ranges::to_json): New.
172         (bounded_ranges::eval_condition): New.
173         (bounded_ranges::contain_p): New.
174         (bounded_ranges::cmp): New.
175         (bounded_ranges_manager::~bounded_ranges_manager): New.
176         (bounded_ranges_manager::get_or_create_empty): New.
177         (bounded_ranges_manager::get_or_create_point): New.
178         (bounded_ranges_manager::get_or_create_range): New.
179         (bounded_ranges_manager::get_or_create_union): New.
180         (bounded_ranges_manager::get_or_create_intersection): New.
181         (bounded_ranges_manager::get_or_create_inverse): New.
182         (bounded_ranges_manager::consolidate): New.
183         (bounded_ranges_manager::get_or_create_ranges_for_switch): New.
184         (bounded_ranges_manager::create_ranges_for_switch): New.
185         (bounded_ranges_manager::make_case_label_ranges): New.
186         (bounded_ranges_manager::log_stats): New.
187         (bounded_ranges_constraint::print): New.
188         (bounded_ranges_constraint::to_json): New.
189         (bounded_ranges_constraint::operator==): New.
190         (bounded_ranges_constraint::add_to_hash): New.
191         (constraint_manager::constraint_manager): Update for new field
192         m_bounded_ranges_constraints.
193         (constraint_manager::operator=): Likewise.
194         (constraint_manager::hash): Likewise.
195         (constraint_manager::operator==): Likewise.
196         (constraint_manager::print): Likewise.
197         (constraint_manager::dump_to_pp): Likewise.
198         (constraint_manager::to_json): Likewise.
199         (constraint_manager::add_unknown_constraint): Update the lhs_ec_id
200         if necessary in existing constraints when combining equivalence
201         classes.  Add similar code for handling
202         m_bounded_ranges_constraints.
203         (constraint_manager::add_constraint_internal): Add comment.
204         (constraint_manager::add_bounded_ranges): New.
205         (constraint_manager::eval_condition): Use new field
206         m_bounded_ranges_constraints.
207         (constraint_manager::purge): Update bounded_ranges_constraint
208         instances.
209         (constraint_manager::canonicalize): Update for new field.
210         (merger_fact_visitor::on_ranges): New.
211         (constraint_manager::for_each_fact): Use new field
212         m_bounded_ranges_constraints.
213         (constraint_manager::validate):  Fix off-by-one error needed due
214         to bug fixed above in add_unknown_constraint.  Validate the EC IDs
215         in m_bounded_ranges_constraints.
216         (constraint_manager::get_range_manager): New.
217         (selftest::assert_dump_bounded_range_eq): New.
218         (ASSERT_DUMP_BOUNDED_RANGE_EQ): New.
219         (selftest::test_bounded_range): New.
220         (selftest::assert_dump_bounded_ranges_eq): New.
221         (ASSERT_DUMP_BOUNDED_RANGES_EQ): New.
222         (selftest::test_bounded_ranges): New.
223         (selftest::run_constraint_manager_tests): Call the new selftests.
224         * constraint-manager.h (struct bounded_range): New.
225         (struct bounded_ranges): New.
226         (template <> struct default_hash_traits<bounded_ranges::key_t>): New.
227         (class bounded_ranges_manager): New.
228         (fact_visitor::on_ranges): New pure virtual function.
229         (class bounded_ranges_constraint): New.
230         (constraint_manager::add_bounded_ranges): New decl.
231         (constraint_manager::get_range_manager): New decl.
232         (constraint_manager::m_bounded_ranges_constraints): New field.
233         * diagnostic-manager.cc (epath_finder::process_worklist_item):
234         Transfer ownership of rc to add_feasibility_problem.
235         * engine.cc (feasibility_problem::dump_to_pp): Use get_model.
236         * feasible-graph.cc (infeasible_node::dump_dot): Update for
237         conversion of m_rc to a pointer.
238         (feasible_graph::add_feasibility_problem): Pass RC by pointer and
239         take ownership.
240         * feasible-graph.h (infeasible_node::infeasible_node): Pass RC by
241         pointer and take ownership.
242         (infeasible_node::~infeasible_node): New.
243         (infeasible_node::m_rc): Convert to a pointer.
244         (feasible_graph::add_feasibility_problem): Pass RC by pointer and
245         take ownership.
246         * region-model-manager.cc: Include
247         "analyzer/constraint-manager.h".
248         (region_model_manager::region_model_manager): Initializer new
249         field m_range_mgr.
250         (region_model_manager::~region_model_manager): Delete it.
251         (region_model_manager::log_stats): Call log_stats on it.
252         * region-model.cc (region_model::add_constraint): Use new subclass
253         rejected_op_constraint.
254         (region_model::apply_constraints_for_gswitch): Reimplement using
255         bounded_ranges_manager.
256         (rejected_constraint::dump_to_pp): Convert to...
257         (rejected_op_constraint::dump_to_pp): ...this.
258         (rejected_ranges_constraint::dump_to_pp): New.
259         * region-model.h (struct purge_stats): Add field
260         m_num_bounded_ranges_constraints.
261         (region_model_manager::get_range_manager): New.
262         (region_model_manager::m_range_mgr): New.
263         (region_model::get_range_manager): New.
264         (struct rejected_constraint): Split into...
265         (class rejected_constraint):...this new abstract base class,
266         and...
267         (class rejected_op_constraint): ...this new concrete subclass.
268         (class rejected_ranges_constraint): New.
269         * supergraph.cc: Include "tree-cfg.h".
270         (supergraph::supergraph): Drop idx param from add_cfg_edge.
271         (supergraph::add_cfg_edge): Drop idx param.
272         (switch_cfg_superedge::switch_cfg_superedge): Move here from
273         header.  Populate m_case_labels with all cases which go to DST.
274         (switch_cfg_superedge::dump_label_to_pp): Reimplement to use
275         m_case_labels.
276         (switch_cfg_superedge::get_case_label): Delete.
277         * supergraph.h (supergraphadd_cfg_edge): Drop "idx" param.
278         (switch_cfg_superedge::switch_cfg_superedge): Drop idx param and
279         move implementation to supergraph.cc.
280         (switch_cfg_superedge::get_case_label): Delete.
281         (switch_cfg_superedge::get_case_labels): New.
282         (switch_cfg_superedge::m_idx): Delete.
283         (switch_cfg_superedge::m_case_labels): New field.
285 2021-08-23  David Malcolm  <dmalcolm@redhat.com>
287         PR analyzer/101875
288         * sm-file.cc (file_diagnostic::describe_state_change): Handle
289         change.m_expr being NULL.
291 2021-08-23  David Malcolm  <dmalcolm@redhat.com>
293         PR analyzer/101837
294         * analyzer.cc (maybe_reconstruct_from_def_stmt): Bail if fn is
295         NULL, and assert that it's non-NULL before passing it to
296         build_call_array_loc.
298 2021-08-23  David Malcolm  <dmalcolm@redhat.com>
300         PR analyzer/101962
301         * region-model.cc (region_model::eval_condition_without_cm):
302         Refactor comparison against zero, adding a check for
303         POINTER_PLUS_EXPR of non-NULL.
305 2021-08-23  David Malcolm  <dmalcolm@redhat.com>
307         * store.cc (bit_range::intersects_p): New overload.
308         (bit_range::operator-): New.
309         (binding_cluster::maybe_get_compound_binding): Handle the partial
310         overlap case.
311         (selftest::test_bit_range_intersects_p): Add test coverage for
312         new overload of bit_range::intersects_p.
313         * store.h (bit_range::intersects_p): New overload.
314         (bit_range::operator-): New.
316 2021-08-23  Ankur Saini  <arsenic@sourceware.org>
318         PR analyzer/102020
319         * diagnostic-manager.cc
320         (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>: Fix typo.
322 2021-08-21  Ankur Saini  <arsenic@sourceware.org>
324         PR analyzer/101980
325         * diagnostic-manager.cc
326         (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>: Use
327         caller_model only when the supergraph_edge doesn't exixt.
328         (diagnostic_manager::prune_for_sm_diagnostic)<case EK_RETURN_EDGE>:
329         Likewise.
330         * engine.cc (exploded_graph::create_dynamic_call): Rename to...
331         (exploded_graph::maybe_create_dynamic_call): ...this, return call
332         creation status.
333         (exploded_graph::process_node): Handle calls which were not dynamically
334         discovered.
335         * exploded-graph.h (exploded_graph::create_dynamic_call): Rename to...
336         (exploded_graph::maybe_create_dynamic_call): ...this.
337         * region-model.cc (region_model::update_for_gcall): New param, use it
338         to push call to frame.
339         (region_model::update_for_call_superedge): Pass callee function to
340         update_for_gcall.
341         * region-model.h (region_model::update_for_gcall): New param.
343 2021-08-18  Ankur Saini  <arsenic@sourceware.org>
345         PR analyzer/97114
346         * region-model.cc (region_model::get_rvalue_1): Add case for
347         OBJ_TYPE_REF.
349 2021-08-18  Ankur Saini  <arsenic@sourceware.org>
351         PR analyzer/100546
352         * analysis-plan.cc (analysis_plan::use_summary_p): Don't use call
353         summaries if there is no callgraph edge
354         * checker-path.cc (call_event::call_event): Handle calls events that
355         are not represented by a supergraph call edge
356         (return_event::return_event): Likewise.
357         (call_event::get_desc): Work with new call_event structure.
358         (return_event::get_desc): Likeise.
359         * checker-path.h (call_event::m_src_snode): New field.
360         (call_event::m_dest_snode): New field.
361         (return_event::m_src_snode): New field.
362         (return_event::m_dest_snode): New field.
363         * diagnostic-manager.cc
364         (diagnostic_manager::prune_for_sm_diagnostic)<case EK_CALL_EDGE>:
365         Refactor to work with edges without callgraph edge.
366         (diagnostic_manager::prune_for_sm_diagnostic)<case EK_RETURN_EDGE>:
367         Likewise.
368         * engine.cc (dynamic_call_info_t::update_model): New function.
369         (dynamic_call_info_t::add_events_to_path): New function.
370         (exploded_graph::create_dynamic_call): New function.
371         (exploded_graph::process_node): Work with dynamically discovered calls.
372         * exploded-graph.h (class dynamic_call_info_t): New class.
373         (exploded_graph::create_dynamic_call): New decl.
374         * program-point.cc (program_point::push_to_call_stack): New function.
375         (program_point::pop_from_call_stack): New function.
376         * program-point.h (program_point::push_to_call_stack): New decl.
377         (program_point::pop_from_call_stack): New decl.
378         * program-state.cc (program_state::push_call): New function.
379         (program_state::returning_call): New function.
380         * program-state.h (program_state::push_call): New decl.
381         (program_state::returning_call): New decl.
382         * region-model.cc (region_model::update_for_gcall) New function.
383         (region_model::update_for_return_gcall): New function.
384         (egion_model::update_for_call_superedge): Get the underlying gcall and
385         update for gcall.
386         (region_model::update_for_return_superedge): Likewise.
387         * region-model.h (region_model::update_for_gcall): New decl.
388         (region_model::update_for_return_gcall): New decl.
389         * state-purge.cc (state_purge_per_ssa_name::process_point): Update to
390         work with calls without underlying cgraph edge.
391         * supergraph.cc (supergraph::supergraph) Split snodes at every callsite.
392         * supergraph.h (supernode::get_returning_call) New accessor.
394 2021-08-04  David Malcolm  <dmalcolm@redhat.com>
396         PR analyzer/101570
397         * analyzer.cc (maybe_reconstruct_from_def_stmt): Add GIMPLE_ASM
398         case.
399         * analyzer.h (class asm_output_svalue): New forward decl.
400         (class reachable_regions): New forward decl.
401         * complexity.cc (complexity::from_vec_svalue): New.
402         * complexity.h (complexity::from_vec_svalue): New decl.
403         * engine.cc (feasibility_state::maybe_update_for_edge): Handle
404         asm stmts by calling on_asm_stmt.
405         * region-model-asm.cc: New file.
406         * region-model-manager.cc
407         (region_model_manager::maybe_fold_asm_output_svalue): New.
408         (region_model_manager::get_or_create_asm_output_svalue): New.
409         (region_model_manager::log_stats): Log m_asm_output_values_map.
410         * region-model.cc (region_model::on_stmt_pre): Handle GIMPLE_ASM.
411         * region-model.h (visitor::visit_asm_output_svalue): New.
412         (region_model_manager::get_or_create_asm_output_svalue): New decl.
413         (region_model_manager::maybe_fold_asm_output_svalue): New decl.
414         (region_model_manager::asm_output_values_map_t): New typedef.
415         (region_model_manager::m_asm_output_values_map): New field.
416         (region_model::on_asm_stmt): New.
417         * store.cc (binding_cluster::on_asm): New.
418         * store.h (binding_cluster::on_asm): New decl.
419         * svalue.cc (svalue::cmp_ptr): Handle SK_ASM_OUTPUT.
420         (asm_output_svalue::dump_to_pp): New.
421         (asm_output_svalue::dump_input): New.
422         (asm_output_svalue::input_idx_to_asm_idx): New.
423         (asm_output_svalue::accept): New.
424         * svalue.h (enum svalue_kind): Add SK_ASM_OUTPUT.
425         (svalue::dyn_cast_asm_output_svalue): New.
426         (class asm_output_svalue): New.
427         (is_a_helper <const asm_output_svalue *>::test): New.
428         (struct default_hash_traits<asm_output_svalue::key_t>): New.
430 2021-08-03  Jakub Jelinek  <jakub@redhat.com>
432         PR analyzer/101721
433         * sm-malloc.cc (known_allocator_p): Only check DECL_FUNCTION_CODE on
434         BUILT_IN_NORMAL builtins.
436 2021-07-29  Ankur Saini  <arsenic@sourceware.org>
438         * call-string.cc (call_string::element_t::operator==): New operator.
439         (call_String::element_t::operator!=): New operator.
440         (call_string::element_t::get_caller_function): New function.
441         (call_string::element_t::get_callee_function): New function.
442         (call_string::call_string): Refactor to Initialise m_elements.
443         (call_string::operator=): Refactor to work with m_elements.
444         (call_string::operator==): Likewise.
445         (call_string::to_json): Likewise.
446         (call_string::hash): Refactor to hash e.m_caller.
447         (call_string::push_call): Refactor to work with m_elements.
448         (call_string::push_call): New overload to push call via supernodes.
449         (call_string::pop): Refactor to work with m_elements.
450         (call_string::calc_recursion_depth): Likewise.
451         (call_string::cmp): Likewise.
452         (call_string::validate): Likewise.
453         (call_string::operator[]): Likewise.
454         * call-string.h (class supernode): New forward decl.
455         (struct call_string::element_t): New struct.
456         (call_string::call_string): Refactor to initialise m_elements.
457         (call_string::bool empty_p): Refactor to work with m_elements.
458         (call_string::get_callee_node): New decl.
459         (call_string::get_caller_node): New decl.
460         (m_elements): Replaces m_return_edges.
461         * program-point.cc (program_point::get_function_at_depth): Refactor to
462         work with new call-string format.
463         (program_point::validate): Likewise.
464         (program_point::on_edge): Likewise.
466 2021-07-28  David Malcolm  <dmalcolm@redhat.com>
468         * region-model.cc (region_model::on_call_pre): Treat
469         IFN_UBSAN_BOUNDS, BUILT_IN_STACK_SAVE, and BUILT_IN_STACK_RESTORE
470         as no-ops, rather than handling them as unknown functions.
472 2021-07-28  David Malcolm  <dmalcolm@redhat.com>
474         * region-model-impl-calls.cc (region_model::impl_call_alloca):
475         Drop redundant return value.
476         (region_model::impl_call_builtin_expect): Likewise.
477         (region_model::impl_call_calloc): Likewise.
478         (region_model::impl_call_malloc): Likewise.
479         (region_model::impl_call_memset): Likewise.
480         (region_model::impl_call_operator_new): Likewise.
481         (region_model::impl_call_operator_delete): Likewise.
482         (region_model::impl_call_strlen): Likewise.
483         * region-model.cc (region_model::on_call_pre): Fix return value of
484         known functions that don't have unknown side-effects.
485         * region-model.h (region_model::impl_call_alloca): Drop redundant
486         return value.
487         (region_model::impl_call_builtin_expect): Likewise.
488         (region_model::impl_call_calloc): Likewise.
489         (region_model::impl_call_malloc): Likewise.
490         (region_model::impl_call_memset): Likewise.
491         (region_model::impl_call_strlen): Likewise.
492         (region_model::impl_call_operator_new): Likewise.
493         (region_model::impl_call_operator_delete): Likewise.
495 2021-07-28  Siddhesh Poyarekar  <siddhesh@gotplt.org>
497         * analyzer.cc (is_named_call_p, is_std_named_call_p): Make
498         first argument a const_tree.
499         * analyzer.h (is_named_call_p, -s_std_named_call_p): Likewise.
500         * sm-malloc.cc (known_allocator_p): New function.
501         (malloc_state_machine::on_stmt): Use it.
503 2021-07-28  Siddhesh Poyarekar  <siddhesh@gotplt.org>
505         * sm-malloc.cc
506         (malloc_state_machine::get_or_create_deallocator): Recognize
507         __builtin_free.
509 2021-07-26  David Malcolm  <dmalcolm@redhat.com>
511         * region-model.cc (region_model::on_call_pre): Always set conjured
512         LHS, not just for SSA names.
514 2021-07-23  David Malcolm  <dmalcolm@redhat.com>
516         * diagnostic-manager.cc
517         (class auto_disable_complexity_checks): New.
518         (epath_finder::explore_feasible_paths): Use it to disable
519         complexity checks whilst processing the worklist.
520         * region-model-manager.cc
521         (region_model_manager::region_model_manager): Initialize
522         m_check_complexity.
523         (region_model_manager::reject_if_too_complex): Bail if
524         m_check_complexity is false.
525         * region-model.h
526         (region_model_manager::enable_complexity_check): New.
527         (region_model_manager::disable_complexity_check): New.
528         (region_model_manager::m_check_complexity): New.
530 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
532         PR analyzer/101547
533         * sm-file.cc (file_leak::emit): Handle m_arg being NULL.
534         (file_leak::describe_final_event): Handle ev.m_expr being NULL.
536 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
538         PR analyzer/101522
539         * store.cc (binding_cluster::purge_state_involving): Don't change
540         m_map whilst iterating through it.
542 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
544         * region-model.cc (region_model::handle_phi): Add "old_state"
545         param and use it.
546         (region_model::update_for_phis): Update so that all of the phi
547         stmts are effectively handled simultaneously, rather than in
548         order.
549         * region-model.h (region_model::handle_phi): Add "old_state"
550         param.
551         * state-purge.cc (self_referential_phi_p): Replace with...
552         (name_used_by_phis_p): ...this new function.
553         (state_purge_per_ssa_name::process_point): Update to use the
554         above, so that all phi stmts at a basic block are effectively
555         considered simultaneously, and only consider the phi arguments for
556         the pertinent in-edge.
557         * supergraph.cc (cfg_superedge::get_phi_arg_idx): New.
558         (cfg_superedge::get_phi_arg): Use the above.
559         * supergraph.h (cfg_superedge::get_phi_arg_idx): New decl.
561 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
563         * state-purge.cc (state_purge_annotator::add_node_annotations):
564         Rather than erroneously always using the NULL in-edge, determine
565         each relevant in-edge, and print the appropriate data for each
566         in-edge.  Use print_needed to print the data as comma-separated
567         lists of SSA names.
568         (print_vec_of_names): Add "within_table" param and use it.
569         (state_purge_annotator::add_stmt_annotations): Factor out
570         collation and printing code into...
571         (state_purge_annotator::print_needed): ...this new function.
572         * state-purge.h (state_purge_annotator::print_needed): New decl.
574 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
576         * program-point.cc (function_point::print): Show src BB index at
577         BEFORE_SUPERNODE.
579 2021-07-21  David Malcolm  <dmalcolm@redhat.com>
581         * svalue.cc (infix_p): New.
582         (binop_svalue::dump_to_pp): Use it to print MIN_EXPR and MAX_EXPR
583         in prefix form, rather than infix.
585 2021-07-19  David Malcolm  <dmalcolm@redhat.com>
587         PR analyzer/101503
588         * constraint-manager.cc (constraint_manager::add_constraint): Use
589         can_have_associated_state_p rather than testing for unknown.
590         (constraint_manager::get_or_add_equiv_class): Likewise.
591         * program-state.cc (sm_state_map::set_state): Likewise.
592         (sm_state_map::impl_set_state): Add assertion.
593         * region-model-manager.cc
594         (region_model_manager::maybe_fold_unaryop): Handle poisoned
595         values.
596         (region_model_manager::maybe_fold_binop): Move handling of unknown
597         values...
598         (region_model_manager::get_or_create_binop): ...to here, and
599         generalize to use can_have_associated_state_p.
600         (region_model_manager::maybe_fold_sub_svalue): Use
601         can_have_associated_state_p rather than testing for unknown.
602         (region_model_manager::maybe_fold_repeated_svalue): Use unknown
603         when the size or repeated value is "unknown"/"poisoned".
604         * region-model.cc (region_model::purge_state_involving): Reject
605         attempts to purge unknown/poisoned svalues, as these svalues
606         should not have state associated with them.
607         * svalue.cc (sub_svalue::sub_svalue): Assert that we're building
608         on top of an svalue with can_have_associated_state_p.
609         (repeated_svalue::repeated_svalue): Likewise.
610         (bits_within_svalue::bits_within_svalue): Likewise.
611         * svalue.h (svalue::can_have_associated_state_p): New.
612         (unknown_svalue::can_have_associated_state_p): New.
613         (poisoned_svalue::can_have_associated_state_p): New.
614         (unaryop_svalue::unaryop_svalue): Assert that we're building on
615         top of an svalue with can_have_associated_state_p.
616         (binop_svalue::binop_svalue): Likewise.
617         (widening_svalue::widening_svalue): Likewise.
619 2021-07-16  David Malcolm  <dmalcolm@redhat.com>
621         * analyzer.h (enum access_direction): New.
622         * engine.cc (exploded_node::on_longjmp): Update for new param of
623         get_store_value.
624         * program-state.cc (program_state::prune_for_point): Likewise.
625         * region-model-impl-calls.cc (region_model::impl_call_memcpy):
626         Replace call to check_for_writable_region with call to
627         check_region_for_write.
628         (region_model::impl_call_memset): Likewise.
629         (region_model::impl_call_strcpy): Likewise.
630         * region-model-reachability.cc (reachable_regions::add): Update
631         for new param of get_store_value.
632         * region-model.cc (region_model::get_rvalue_1): Likewise, also for
633         get_rvalue_for_bits.
634         (region_model::get_store_value): Add ctxt param and use it to call
635         check_region_for_read.
636         (region_model::get_rvalue_for_bits): Add ctxt param and use it to
637         call get_store_value.
638         (region_model::check_region_access): New.
639         (region_model::check_region_for_write): New.
640         (region_model::check_region_for_read): New.
641         (region_model::set_value): Update comment.  Replace call to
642         check_for_writable_region with call to check_region_for_write.
643         * region-model.h (region_model::get_rvalue_for_bits): Add ctxt
644         param.
645         (region_model::get_store_value): Add ctxt param.
646         (region_model::check_region_access): New decl.
647         (region_model::check_region_for_write): New decl.
648         (region_model::check_region_for_read): New decl.
649         * region.cc (region_model::copy_region): Update call to
650         get_store_value.
651         * svalue.cc (initial_svalue::implicitly_live_p): Likewise.
653 2021-07-16  David Malcolm  <dmalcolm@redhat.com>
655         * engine.cc (exploded_node::on_stmt_pre): Handle
656         __analyzer_dump_state.
657         * program-state.cc (extrinsic_state::get_sm_idx_by_name): New.
658         (program_state::impl_call_analyzer_dump_state): New.
659         * program-state.h (extrinsic_state::get_sm_idx_by_name): New decl.
660         (program_state::impl_call_analyzer_dump_state): New decl.
661         * region-model-impl-calls.cc
662         (call_details::get_arg_string_literal): New.
663         * region-model.h (call_details::get_arg_string_literal): New decl.
665 2021-07-16  David Malcolm  <dmalcolm@redhat.com>
667         * program-state.cc (program_state::detect_leaks): Simplify using
668         svalue::maybe_get_region.
669         * region-model-impl-calls.cc (region_model::impl_call_fgets): Likewise.
670         (region_model::impl_call_fread): Likewise.
671         (region_model::impl_call_free): Likewise.
672         (region_model::impl_call_operator_delete): Likewise.
673         * region-model.cc (selftest::test_stack_frames): Likewise.
674         (selftest::test_state_merging): Likewise.
675         * svalue.cc (svalue::maybe_get_region): New.
676         * svalue.h (svalue::maybe_get_region): New decl.
678 2021-07-15  David Malcolm  <dmalcolm@redhat.com>
680         * svalue.h (is_a_helper <placeholder_svalue *>::test): Make
681         param and template param const.
682         (is_a_helper <widening_svalue *>::test): Likewise.
683         (is_a_helper <compound_svalue *>::test): Likewise.
684         (is_a_helper <conjured_svalue *>::test): Likewise.
686 2021-07-15  David Malcolm  <dmalcolm@redhat.com>
688         PR analyzer/95006
689         PR analyzer/94713
690         PR analyzer/94714
691         * analyzer.cc (maybe_reconstruct_from_def_stmt): Split out
692         GIMPLE_ASSIGN case into...
693         (get_diagnostic_tree_for_gassign_1): New.
694         (get_diagnostic_tree_for_gassign): New.
695         * analyzer.h (get_diagnostic_tree_for_gassign): New decl.
696         * analyzer.opt (Wanalyzer-write-to-string-literal): New.
697         * constraint-manager.cc (class svalue_purger): New.
698         (constraint_manager::purge_state_involving): New.
699         * constraint-manager.h
700         (constraint_manager::purge_state_involving): New.
701         * diagnostic-manager.cc (saved_diagnostic::supercedes_p): New.
702         (dedupe_winners::handle_interactions): New.
703         (diagnostic_manager::emit_saved_diagnostics): Call it.
704         * diagnostic-manager.h (saved_diagnostic::supercedes_p): New decl.
705         * engine.cc (impl_region_model_context::warn): Convert return type
706         to bool.  Return false if the diagnostic isn't saved.
707         (impl_region_model_context::purge_state_involving): New.
708         (impl_sm_context::get_state): Use NULL ctxt when querying old
709         rvalue.
710         (impl_sm_context::set_next_state): Use new sval when querying old
711         state.
712         (class dump_path_diagnostic): Move to region-model.cc
713         (exploded_node::on_stmt): Move to on_stmt_pre and on_stmt_post.
714         Remove call to purge_state_involving.
715         (exploded_node::on_stmt_pre): New, based on the above.  Move most
716         of it to region_model::on_stmt_pre.
717         (exploded_node::on_stmt_post): Likewise, moving to
718         region_model::on_stmt_post.
719         (class stale_jmp_buf): Fix parent class to use curiously recurring
720         template pattern.
721         (feasibility_state::maybe_update_for_edge): Call on_call_pre and
722         on_call_post on gcalls.
723         * exploded-graph.h (impl_region_model_context::warn): Return bool.
724         (impl_region_model_context::purge_state_involving): New decl.
725         (exploded_node::on_stmt_pre): New decl.
726         (exploded_node::on_stmt_post): New decl.
727         * pending-diagnostic.h (pending_diagnostic::use_of_uninit_p): New.
728         (pending_diagnostic::supercedes_p): New.
729         * program-state.cc (sm_state_map::get_state): Inherit state for
730         conjured_svalue as well as initial_svalue.
731         (sm_state_map::purge_state_involving): Also support SK_CONJURED.
732         * region-model-impl-calls.cc (call_details::get_uncertainty):
733         Handle m_ctxt being NULL.
734         (call_details::get_or_create_conjured_svalue): New.
735         (region_model::impl_call_fgets): New.
736         (region_model::impl_call_fread): New.
737         * region-model-manager.cc
738         (region_model_manager::get_or_create_initial_value): Return an
739         uninitialized poisoned value for regions that can't have initial
740         values.
741         * region-model-reachability.cc
742         (reachable_regions::mark_escaped_clusters): Handle ctxt being
743         NULL.
744         * region-model.cc (region_to_value_map::purge_state_involving): New.
745         (poisoned_value_diagnostic::use_of_uninit_p): New.
746         (poisoned_value_diagnostic::emit): Handle POISON_KIND_UNINIT.
747         (poisoned_value_diagnostic::describe_final_event): Likewise.
748         (region_model::check_for_poison): New.
749         (region_model::on_assignment): Call it.
750         (class dump_path_diagnostic): Move here from engine.cc.
751         (region_model::on_stmt_pre): New, based on exploded_node::on_stmt.
752         (region_model::on_call_pre): Move the setting of the LHS to a
753         conjured svalue to before the checks for specific functions.
754         Handle "fgets", "fgets_unlocked", and "fread".
755         (region_model::purge_state_involving): New.
756         (region_model::handle_unrecognized_call): Handle ctxt being NULL.
757         (region_model::get_rvalue): Call check_for_poison.
758         (selftest::test_stack_frames): Use NULL for context when getting
759         uninitialized rvalue.
760         (selftest::test_alloca): Likewise.
761         * region-model.h (region_to_value_map::purge_state_involving): New
762         decl.
763         (call_details::get_or_create_conjured_svalue): New decl.
764         (region_model::on_stmt_pre): New decl.
765         (region_model::purge_state_involving): New decl.
766         (region_model::impl_call_fgets): New decl.
767         (region_model::impl_call_fread): New decl.
768         (region_model::check_for_poison): New decl.
769         (region_model_context::warn): Return bool.
770         (region_model_context::purge_state_involving): New.
771         (noop_region_model_context::warn): Return bool.
772         (noop_region_model_context::purge_state_involving): New.
773         (test_region_model_context:: warn): Return bool.
774         * region.cc (region::get_memory_space): New.
775         (region::can_have_initial_svalue_p): New.
776         (region::involves_p): New.
777         * region.h (enum memory_space): New.
778         (region::get_memory_space): New decl.
779         (region::can_have_initial_svalue_p): New decl.
780         (region::involves_p): New decl.
781         * sm-malloc.cc (use_after_free::supercedes_p): New.
782         * store.cc (binding_cluster::purge_state_involving): New.
783         (store::purge_state_involving): New.
784         * store.h (class symbolic_binding): New forward decl.
785         (binding_key::dyn_cast_symbolic_binding): New.
786         (symbolic_binding::dyn_cast_symbolic_binding): New.
787         (binding_cluster::purge_state_involving): New.
788         (store::purge_state_involving): New.
789         * svalue.cc (svalue::can_merge_p): Reject attempts to merge
790         poisoned svalues with other svalues, so that we identify
791         paths in which a variable is conditionally uninitialized.
792         (involvement_visitor::visit_conjured_svalue): New.
793         (svalue::involves_p): Also handle SK_CONJURED.
794         (poison_kind_to_str): Handle POISON_KIND_UNINIT.
795         (poisoned_svalue::maybe_fold_bits_within): New.
796         * svalue.h (enum poison_kind): Add POISON_KIND_UNINIT.
797         (poisoned_svalue::maybe_fold_bits_within): New decl.
799 2021-07-15  David Malcolm  <dmalcolm@redhat.com>
801         * analyzer.opt (fdump-analyzer-exploded-paths): New.
802         * diagnostic-manager.cc
803         (diagnostic_manager::emit_saved_diagnostic): Implement it.
804         * engine.cc (exploded_path::dump_to_pp): Add ext_state param and
805         use it to dump states if non-NULL.
806         (exploded_path::dump): Likewise.
807         (exploded_path::dump_to_file): New.
808         * exploded-graph.h (exploded_path::dump_to_pp): Add ext_state
809         param.
810         (exploded_path::dump): Likewise.
811         (exploded_path::dump): Likewise.
812         (exploded_path::dump_to_file): New.
814 2021-07-15  David Malcolm  <dmalcolm@redhat.com>
816         * analyzer.cc (fixup_tree_for_diagnostic_1): Use DECL_DEBUG_EXPR
817         if it's available.
818         * engine.cc (readability): Likewise.
820 2021-07-15  David Malcolm  <dmalcolm@redhat.com>
822         * state-purge.cc (self_referential_phi_p): New.
823         (state_purge_per_ssa_name::process_point): Don't purge an SSA name
824         at its def-stmt if the def-stmt is self-referential.
826 2021-07-07  David Malcolm  <dmalcolm@redhat.com>
828         * diagnostic-manager.cc (null_assignment_sm_context::get_state):
829         New overload.
830         (null_assignment_sm_context::set_next_state): New overload.
831         (null_assignment_sm_context::get_diagnostic_tree): New.
832         * engine.cc (impl_sm_context::get_state): New overload.
833         (impl_sm_context::set_next_state): New overload.
834         (impl_sm_context::get_diagnostic_tree): New overload.
835         (impl_region_model_context::on_condition): Convert params from
836         tree to const svalue *.
837         * exploded-graph.h (impl_region_model_context::on_condition):
838         Likewise.
839         * region-model.cc (region_model::on_call_pre): Move handling of
840         internal calls to before checking for get_fndecl_for_call.
841         (region_model::add_constraints_from_binop): New.
842         (region_model::add_constraint): Split out into a new overload
843         working on const svalue * rather than tree.  Call
844         add_constraints_from_binop.  Drop call to
845         add_any_constraints_from_ssa_def_stmt.
846         (region_model::add_any_constraints_from_ssa_def_stmt): Delete.
847         (region_model::add_any_constraints_from_gassign): Delete.
848         (region_model::add_any_constraints_from_gcall): Delete.
849         * region-model.h
850         (region_model::add_any_constraints_from_ssa_def_stmt): Delete.
851         (region_model::add_any_constraints_from_gassign): Delete.
852         (region_model::add_any_constraints_from_gcall): Delete.
853         (region_model::add_constraint): Add overload decl.
854         (region_model::add_constraints_from_binop): New decl.
855         (region_model_context::on_condition): Convert params from tree to
856         const svalue *.
857         (noop_region_model_context::on_condition): Likewise.
858         * sm-file.cc (fileptr_state_machine::condition): Likewise.
859         * sm-malloc.cc (malloc_state_machine::on_condition): Likewise.
860         * sm-pattern-test.cc: Include tristate.h, selftest.h,
861         analyzer/call-string.h, analyzer/program-point.h,
862         analyzer/store.h, and analyzer/region-model.h.
863         (pattern_test_state_machine::on_condition): Convert params from tree to
864         const svalue *.
865         * sm-sensitive.cc (sensitive_state_machine::on_condition): Delete.
866         * sm-signal.cc (signal_state_machine::on_condition): Delete.
867         * sm-taint.cc (taint_state_machine::on_condition): Convert params
868         from tree to const svalue *.
869         * sm.cc: Include tristate.h, selftest.h, analyzer/call-string.h,
870         analyzer/program-point.h, analyzer/store.h, and
871         analyzer/region-model.h.
872         (any_pointer_p): Add overload taking const svalue *sval.
873         * sm.h (any_pointer_p): Add overload taking const svalue *sval.
874         (state_machine::on_condition): Convert params from tree to
875         const svalue *.  Provide no-op default implementation.
876         (sm_context::get_state): Add overload taking const svalue *sval.
877         (sm_context::set_next_state): Likewise.
878         (sm_context::on_transition): Likewise.
879         (sm_context::get_diagnostic_tree): Likewise.
880         * svalue.cc (svalue::all_zeroes_p): New.
881         (constant_svalue::all_zeroes_p): New.
882         (repeated_svalue::all_zeroes_p): Convert to vfunc.
883         * svalue.h (svalue::all_zeroes_p): New decl.
884         (constant_svalue::all_zeroes_p): New decl.
885         (repeated_svalue::all_zeroes_p): Convert decl to vfunc.
887 2021-06-30  David Malcolm  <dmalcolm@redhat.com>
889         PR analyzer/95006
890         * analyzer.h (class repeated_svalue): New forward decl.
891         (class bits_within_svalue): New forward decl.
892         (class sized_region): New forward decl.
893         (get_field_at_bit_offset): New forward decl.
894         * engine.cc (exploded_graph::get_or_create_node): Validate the
895         merged state.
896         (exploded_graph::maybe_process_run_of_before_supernode_enodes):
897         Validate the states at each stage.
898         * program-state.cc (program_state::validate): Validate
899         m_region_model.
900         * region-model-impl-calls.cc (region_model::impl_call_memset):
901         Replace special-case logic for handling constant sizes with
902         a call to fill_region of a sized_region with the given fill value.
903         * region-model-manager.cc (maybe_undo_optimize_bit_field_compare):
904         Drop DK_direct.
905         (region_model_manager::maybe_fold_sub_svalue):  Fold element-based
906         subregions of an initial value into initial values of an element.
907         Fold subvalues of repeated svalues.
908         (region_model_manager::maybe_fold_repeated_svalue): New.
909         (region_model_manager::get_or_create_repeated_svalue): New.
910         (get_bit_range_for_field): New.
911         (get_byte_range_for_field): New.
912         (get_field_at_byte_range): New.
913         (region_model_manager::maybe_fold_bits_within_svalue): New.
914         (region_model_manager::get_or_create_bits_within): New.
915         (region_model_manager::get_sized_region): New.
916         (region_model_manager::log_stats): Update for addition of
917         m_repeated_values_map, m_bits_within_values_map, and
918         m_sized_regions.
919         * region-model.cc (region_model::validate): New.
920         (region_model::on_assignment): Drop enum binding_kind.
921         (region_model::get_initial_value_for_global): Likewise.
922         (region_model::get_rvalue_for_bits): Replace body with call to
923         get_or_create_bits_within.
924         (region_model::get_capacity): Handle RK_SIZED.
925         (region_model::set_value): Drop enum binding_kind.
926         (region_model::fill_region): New.
927         (region_model::get_representative_path_var_1): Handle RK_SIZED.
928         * region-model.h (visitor::visit_repeated_svalue): New.
929         (visitor::visit_bits_within_svalue): New.
930         (region_model_manager::get_or_create_repeated_svalue): New decl.
931         (region_model_manager::get_or_create_bits_within): New decl.
932         (region_model_manager::get_sized_region): New decl.
933         (region_model_manager::maybe_fold_repeated_svalue): New decl.
934         (region_model_manager::maybe_fold_bits_within_svalue): New decl.
935         (region_model_manager::repeated_values_map_t): New typedef.
936         (region_model_manager::m_repeated_values_map): New field.
937         (region_model_manager::bits_within_values_map_t): New typedef.
938         (region_model_manager::m_bits_within_values_map): New field.
939         (region_model_manager::m_sized_regions): New field.
940         (region_model::fill_region): New decl.
941         * region.cc (region::get_base_region): Handle RK_SIZED.
942         (region::base_region_p): Likewise.
943         (region::get_byte_size_sval): New.
944         (get_field_at_bit_offset): Make non-static.
945         (region::calc_offset): Move implementation of cases to
946         get_relative_concrete_offset vfunc implementations.  Handle
947         RK_SIZED.
948         (region::get_relative_concrete_offset): New.
949         (decl_region::get_svalue_for_initializer): Drop enum binding_kind.
950         (field_region::get_relative_concrete_offset): New, from
951         region::calc_offset.
952         (element_region::get_relative_concrete_offset): Likewise.
953         (offset_region::get_relative_concrete_offset): Likewise.
954         (sized_region::accept): New.
955         (sized_region::dump_to_pp): New.
956         (sized_region::get_byte_size): New.
957         (sized_region::get_bit_size): New.
958         * region.h (enum region_kind): Add RK_SIZED.
959         (region::dyn_cast_sized_region): New.
960         (region::get_byte_size): Make virtual.
961         (region::get_bit_size): Likewise.
962         (region::get_byte_size_sval): New decl.
963         (region::get_relative_concrete_offset): New decl.
964         (field_region::get_relative_concrete_offset): New decl.
965         (element_region::get_relative_concrete_offset): Likewise.
966         (offset_region::get_relative_concrete_offset): Likewise.
967         (class sized_region): New.
968         * store.cc (binding_kind_to_string): Delete.
969         (binding_key::make): Drop enum binding_kind.
970         (binding_key::dump_to_pp): Delete.
971         (binding_key::cmp_ptrs): Drop enum binding_kind.
972         (bit_range::contains_p): New.
973         (byte_range::dump): New.
974         (byte_range::contains_p): New.
975         (byte_range::cmp): New.
976         (concrete_binding::dump_to_pp): Drop enum binding_kind.
977         (concrete_binding::cmp_ptr_ptr): Likewise.
978         (symbolic_binding::dump_to_pp): Likewise.
979         (symbolic_binding::cmp_ptr_ptr): Likewise.
980         (binding_map::apply_ctor_val_to_range): Likewise.
981         (binding_map::apply_ctor_pair_to_child_region): Likewise.
982         (binding_map::get_overlapping_bindings): New.
983         (binding_map::remove_overlapping_bindings): New.
984         (binding_cluster::validate): New.
985         (binding_cluster::bind): Drop enum binding_kind.
986         (binding_cluster::bind_compound_sval): Likewise.
987         (binding_cluster::purge_region): Likewise.
988         (binding_cluster::zero_fill_region): Reimplement in terms of...
989         (binding_cluster::fill_region): New.
990         (binding_cluster::mark_region_as_unknown): Drop enum binding_kind.
991         (binding_cluster::get_binding): Likewise.
992         (binding_cluster::get_binding_recursive): Likewise.
993         (binding_cluster::get_any_binding): Likewise.
994         (binding_cluster::maybe_get_compound_binding): Reimplement.
995         (binding_cluster::get_overlapping_bindings): Delete.
996         (binding_cluster::remove_overlapping_bindings): Reimplement in
997         terms of binding_map::remove_overlapping_bindings.
998         (binding_cluster::can_merge_p): Update for removal of
999         enum binding_kind.
1000         (binding_cluster::on_unknown_fncall): Drop enum binding_kind.
1001         (binding_cluster::maybe_get_simple_value): Likewise.
1002         (store_manager::get_concrete_binding): Likewise.
1003         (store_manager::get_symbolic_binding): Likewise.
1004         (store::validate): New.
1005         (store::set_value): Drop enum binding_kind.
1006         (store::zero_fill_region): Reimplement in terms of...
1007         (store::fill_region): New.
1008         (selftest::test_binding_key_overlap): Drop enum binding_kind.
1009         * store.h (enum binding_kind): Delete.
1010         (binding_kind_to_string): Delete decl.
1011         (binding_key::make): Drop enum binding_kind.
1012         (binding_key::dump_to_pp): Make pure virtual.
1013         (binding_key::get_kind): Delete.
1014         (binding_key::mark_deleted): Delete.
1015         (binding_key::mark_empty): Delete.
1016         (binding_key::is_deleted): Delete.
1017         (binding_key::is_empty): Delete.
1018         (binding_key::binding_key): Delete.
1019         (binding_key::impl_hash): Delete.
1020         (binding_key::impl_eq): Delete.
1021         (binding_key::m_kind): Delete.
1022         (bit_range::get_last_bit_offset): New.
1023         (bit_range::contains_p): New.
1024         (byte_range::contains_p): New.
1025         (byte_range::operator==): New.
1026         (byte_range::get_start_byte_offset): New.
1027         (byte_range::get_next_byte_offset): New.
1028         (byte_range::get_last_byte_offset): New.
1029         (byte_range::as_bit_range): New.
1030         (byte_range::cmp): New.
1031         (concrete_binding::concrete_binding): Drop enum binding_kind.
1032         (concrete_binding::hash): Likewise.
1033         (concrete_binding::operator==): Likewise.
1034         (concrete_binding::mark_deleted): New.
1035         (concrete_binding::mark_empty): New.
1036         (concrete_binding::is_deleted): New.
1037         (concrete_binding::is_empty): New.
1038         (default_hash_traits<ana::concrete_binding>::empty_zero_p): Make false.
1039         (symbolic_binding::symbolic_binding): Drop enum binding_kind.
1040         (symbolic_binding::hash): Likewise.
1041         (symbolic_binding::operator==): Likewise.
1042         (symbolic_binding::mark_deleted): New.
1043         (symbolic_binding::mark_empty): New.
1044         (symbolic_binding::is_deleted): New.
1045         (symbolic_binding::is_empty): New.
1046         (binding_map::remove_overlapping_bindings): New decl.
1047         (binding_map::get_overlapping_bindings): New decl.
1048         (binding_cluster::validate): New decl.
1049         (binding_cluster::bind): Drop enum binding_kind.
1050         (binding_cluster::fill_region): New decl.
1051         (binding_cluster::get_binding): Drop enum binding_kind.
1052         (binding_cluster::get_binding_recursive): Likewise.
1053         (binding_cluster::get_overlapping_bindings): Delete.
1054         (store::validate): New decl.
1055         (store::set_value): Drop enum binding_kind.
1056         (store::fill_region): New decl.
1057         (store_manager::get_concrete_binding): Drop enum binding_kind.
1058         (store_manager::get_symbolic_binding): Likewise.
1059         * svalue.cc (svalue::cmp_ptr): Handle SK_REPEATED and
1060         SK_BITS_WITHIN.
1061         (svalue::extract_bit_range): New.
1062         (svalue::maybe_fold_bits_within): New.
1063         (constant_svalue::maybe_fold_bits_within): New.
1064         (unknown_svalue::maybe_fold_bits_within): New.
1065         (unaryop_svalue::maybe_fold_bits_within): New.
1066         (repeated_svalue::repeated_svalue): New.
1067         (repeated_svalue::dump_to_pp): New.
1068         (repeated_svalue::accept): New.
1069         (repeated_svalue::all_zeroes_p): New.
1070         (repeated_svalue::maybe_fold_bits_within): New.
1071         (bits_within_svalue::bits_within_svalue): New.
1072         (bits_within_svalue::dump_to_pp): New.
1073         (bits_within_svalue::maybe_fold_bits_within): New.
1074         (bits_within_svalue::accept): New.
1075         (bits_within_svalue::implicitly_live_p): New.
1076         (compound_svalue::maybe_fold_bits_within): New.
1077         * svalue.h (enum svalue_kind): Add SK_REPEATED and SK_BITS_WITHIN.
1078         (svalue::dyn_cast_repeated_svalue): New.
1079         (svalue::dyn_cast_bits_within_svalue): New.
1080         (svalue::extract_bit_range): New decl.
1081         (svalue::maybe_fold_bits_within): New vfunc decl.
1082         (region_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1083         (region_svalue::key_t::is_empty): Likewise.
1084         (default_hash_traits<region_svalue::key_t>::empty_zero_p): Make false.
1085         (constant_svalue::maybe_fold_bits_within): New.
1086         (unknown_svalue::maybe_fold_bits_within): New.
1087         (poisoned_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1088         (poisoned_svalue::key_t::is_empty): Likewise.
1089         (default_hash_traits<poisoned_svalue::key_t>::empty_zero_p): Make
1090         false.
1091         (setjmp_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1092         (setjmp_svalue::key_t::is_empty): Likewise.
1093         (default_hash_traits<setjmp_svalue::key_t>::empty_zero_p): Make
1094         false.
1095         (unaryop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1096         (unaryop_svalue::key_t::is_empty): Likewise.
1097         (unaryop_svalue::maybe_fold_bits_within): New.
1098         (default_hash_traits<unaryop_svalue::key_t>::empty_zero_p): Make
1099         false.
1100         (binop_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1101         (binop_svalue::key_t::is_empty): Likewise.
1102         (default_hash_traits<binop_svalue::key_t>::empty_zero_p): Make
1103         false.
1104         (sub_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1105         (sub_svalue::key_t::is_empty): Likewise.
1106         (default_hash_traits<sub_svalue::key_t>::empty_zero_p): Make
1107         false.
1108         (class repeated_svalue): New.
1109         (is_a_helper <const repeated_svalue *>::test): New.
1110         (struct default_hash_traits<repeated_svalue::key_t>): New.
1111         (class bits_within_svalue): New.
1112         (is_a_helper <const bits_within_svalue *>::test): New.
1113         (struct default_hash_traits<bits_within_svalue::key_t>): New.
1114         (widening_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1115         (widening_svalue::key_t::is_empty): Likewise.
1116         (default_hash_traits<widening_svalue::key_t>::empty_zero_p): Make
1117         false.
1118         (compound_svalue::key_t::mark_empty): Use 2 rather than NULL_TREE.
1119         (compound_svalue::key_t::is_empty): Likewise.
1120         (compound_svalue::maybe_fold_bits_within): New.
1121         (default_hash_traits<compound_svalue::key_t>::empty_zero_p): Make
1122         false.
1124 2021-06-28  David Malcolm  <dmalcolm@redhat.com>
1126         * analyzer.h (byte_offset_t): New typedef.
1127         * store.cc (bit_range::dump_to_pp): Dump as a byte range if
1128         possible.
1129         (bit_range::as_byte_range): New.
1130         (byte_range::dump_to_pp): New.
1131         * store.h (class byte_range): New forward decl.
1132         (struct bit_range): Add comment.
1133         (bit_range::as_byte_range): New decl.
1134         (struct byte_range): New.
1136 2021-06-22  David Malcolm  <dmalcolm@redhat.com>
1138         PR analyzer/101143
1139         * region-model.cc (compat_types_p): New function.
1140         (region_model::create_region_for_heap_alloc): Convert assertion to
1141         an error check.
1142         (region_model::create_region_for_alloca): Likewise.
1144 2021-06-18  David Malcolm  <dmalcolm@redhat.com>
1146         * store.cc (binding_cluster::get_any_binding): Make symbolic reads
1147         from a cluster with concrete bindings return unknown.
1149 2021-06-18  David Malcolm  <dmalcolm@redhat.com>
1151         * region-model-manager.cc
1152         (region_model_manager::get_or_create_int_cst): New.
1153         (region_model_manager::maybe_undo_optimize_bit_field_compare): Use
1154         it to simplify away a local tree.
1155         * region-model.cc (region_model::on_setjmp): Likewise.
1156         (region_model::on_longjmp): Likewise.
1157         * region-model.h (region_model_manager::get_or_create_int_cst):
1158         New decl.
1159         * store.cc (binding_cluster::zero_fill_region): Use it to simplify
1160         away a local tree.
1162 2021-06-18  David Malcolm  <dmalcolm@redhat.com>
1164         * checker-path.cc (class custom_event): Make abstract to allow for
1165         custom vfuncs, splitting existing implementation into...
1166         (class precanned_custom_event): New subclass.
1167         (custom_event::get_desc): Move to...
1168         (precanned_custom_event::get_desc): ...subclass.
1169         * checker-path.h (class custom_event): Make abstract to allow for
1170         custom vfuncs, splitting existing implementation into...
1171         (class precanned_custom_event): New subclass.
1172         * diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
1173         Use precanned_custom_event.
1174         * engine.cc
1175         (stale_jmp_buf::maybe_add_custom_events_for_superedge): Likewise.
1176         * sm-signal.cc (signal_delivery_edge_info_t::add_events_to_path):
1177         Likewise.
1179 2021-06-15  David Malcolm  <dmalcolm@redhat.com>
1181         PR analyzer/99212
1182         PR analyzer/101082
1183         * engine.cc: Include "target.h".
1184         (impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
1185         WORDS_BIG_ENDIAN.
1186         * region-model-manager.cc
1187         (region_model_manager::maybe_fold_binop): Move support for masking
1188         via ARG0 & CST into...
1189         (region_model_manager::maybe_undo_optimize_bit_field_compare):
1190         ...this new function.  Flatten by converting from nested
1191         conditionals to a series of early return statements to reject
1192         failures.  Reject if type is not unsigned_char_type_node.
1193         Handle BYTES_BIG_ENDIAN when determining which bits are bound
1194         in the binding_map.
1195         * region-model.h
1196         (region_model_manager::maybe_undo_optimize_bit_field_compare):
1197         New decl.
1198         * store.cc (bit_range::dump): New function.
1199         * store.h (bit_range::dump): New decl.
1201 2021-06-15  David Malcolm  <dmalcolm@redhat.com>
1203         * engine.cc (exploded_node::on_stmt): Handle __analyzer_dump_capacity.
1204         (exploded_node::on_stmt): Drop m_sm_changes from on_stmt_flags.
1205         (state_change_requires_new_enode_p): New function...
1206         (exploded_graph::process_node): Call it, rather than querying
1207         flags.m_sm_changes, so that dynamic-extent differences can also
1208         trigger the splitting of nodes.
1209         * exploded-graph.h (struct on_stmt_flags): Drop field m_sm_changes.
1210         * program-state.cc (program_state::detect_leaks): Purge dead
1211         heap-allocated regions from dynamic extents.
1212         (selftest::test_program_state_1): Fix type of "size_in_bytes".
1213         (selftest::test_program_state_merging): Likewise.
1214         * region-model-impl-calls.cc
1215         (region_model::impl_call_analyzer_dump_capacity): New.
1216         (region_model::impl_call_free): Remove dynamic extents from the
1217         freed region.
1218         * region-model-reachability.h
1219         (reachable_regions::begin_mutable_base_regs): New.
1220         (reachable_regions::end_mutable_base_regs): New.
1221         * region-model.cc: Include "tree-object-size.h".
1222         (region_model::region_model): Support new field m_dynamic_extents.
1223         (region_model::operator=): Likewise.
1224         (region_model::operator==): Likewise.
1225         (region_model::dump_to_pp): Dump sizes of dynamic regions.
1226         (region_model::handle_unrecognized_call): Purge dynamic extents
1227         from any regions that have escaped mutably:.
1228         (region_model::get_capacity): New function.
1229         (region_model::add_constraint): Unset dynamic extents when a
1230         heap-allocated region's address is NULL.
1231         (region_model::unbind_region_and_descendents): Purge dynamic
1232         extents of unbound regions.
1233         (region_model::can_merge_with_p): Call
1234         m_dynamic_extents.can_merge_with_p.
1235         (region_model::create_region_for_heap_alloc): Assert that
1236         size_in_bytes's type is compatible with size_type_node.  Update
1237         for renaming of record_dynamic_extents to set_dynamic_extents.
1238         (region_model::create_region_for_alloca): Likewise.
1239         (region_model::record_dynamic_extents): Rename to...
1240         (region_model::set_dynamic_extents): ...this.  Assert that
1241         size_in_bytes's type is compatible with size_type_node.  Add it
1242         to the m_dynamic_extents map.
1243         (region_model::get_dynamic_extents): New.
1244         (region_model::unset_dynamic_extents): New.
1245         (selftest::test_state_merging): Fix type of "size".
1246         (selftest::test_malloc_constraints): Likewise.
1247         (selftest::test_malloc): Verify dynamic extents.
1248         (selftest::test_alloca): Likewise.
1249         * region-model.h (region_to_value_map::is_empty): New.
1250         (region_model::dynamic_extents_t): New typedef.
1251         (region_model::impl_call_analyzer_dump_capacity): New decl.
1252         (region_model::get_dynamic_extents): New function.
1253         (region_model::get_dynamic_extents): New decl.
1254         (region_model::set_dynamic_extents): New decl.
1255         (region_model::unset_dynamic_extents): New decl.
1256         (region_model::get_capacity): New decl.
1257         (region_model::record_dynamic_extents): Rename to set_dynamic_extents.
1258         (region_model::m_dynamic_extents): New field.
1260 2021-06-15  David Malcolm  <dmalcolm@redhat.com>
1262         * region-model.cc (region_to_value_map::operator=): New.
1263         (region_to_value_map::operator==): New.
1264         (region_to_value_map::dump_to_pp): New.
1265         (region_to_value_map::dump): New.
1266         (region_to_value_map::can_merge_with_p): New.
1267         * region-model.h (class region_to_value_map): New class.
1269 2021-06-13  Trevor Saunders  <tbsaunde@tbsaunde.org>
1271         * call-string.cc (call_string::call_string): Use range based for
1272         to iterate over vec<>.
1273         (call_string::to_json): Likewise.
1274         (call_string::hash): Likewise.
1275         (call_string::calc_recursion_depth): Likewise.
1276         * checker-path.cc (checker_path::fixup_locations): Likewise.
1277         * constraint-manager.cc (equiv_class::equiv_class): Likewise.
1278         (equiv_class::to_json): Likewise.
1279         (equiv_class::hash): Likewise.
1280         (constraint_manager::to_json): Likewise.
1281         * engine.cc (impl_region_model_context::on_svalue_leak):
1282         Likewise.
1283         (on_liveness_change): Likewise.
1284         (impl_region_model_context::on_unknown_change): Likewise.
1285         * program-state.cc (sm_state_map::set_state): Likewise.
1286         * region-model.cc (test_canonicalization_4): Likewise.
1288 2021-06-11  David Malcolm  <dmalcolm@redhat.com>
1290         * engine.cc (worklist::key_t::cmp): Move sort by call_string to
1291         before SCC.
1293 2021-06-09  David Malcolm  <dmalcolm@redhat.com>
1295         * region-model.cc (region_model::get_lvalue_1): Make const.
1296         (region_model::get_lvalue): Likewise.
1297         (region_model::get_rvalue_1): Likewise.
1298         (region_model::get_rvalue): Likewise.
1299         (region_model::deref_rvalue): Likewise.
1300         (region_model::get_rvalue_for_bits): Likewise.
1301         * region-model.h (region_model::get_lvalue): Likewise.
1302         (region_model::get_rvalue): Likewise.
1303         (region_model::deref_rvalue): Likewise.
1304         (region_model::get_rvalue_for_bits): Likewise.
1305         (region_model::get_lvalue_1): Likewise.
1306         (region_model::get_rvalue_1): Likewise.
1308 2021-06-08  David Malcolm  <dmalcolm@redhat.com>
1310         PR analyzer/99212
1311         * region-model-manager.cc
1312         (region_model_manager::maybe_fold_binop): Add support for folding
1313         BIT_AND_EXPR of compound_svalue and a mask constant.
1314         * region-model.cc (region_model::get_rvalue_1): Implement
1315         BIT_FIELD_REF in terms of...
1316         (region_model::get_rvalue_for_bits): New function.
1317         * region-model.h (region_model::get_rvalue_for_bits): New decl.
1318         * store.cc (bit_range::from_mask): New function.
1319         (selftest::test_bit_range_intersects_p): New selftest.
1320         (selftest::assert_bit_range_from_mask_eq): New.
1321         (ASSERT_BIT_RANGE_FROM_MASK_EQ): New macro.
1322         (selftest::assert_no_bit_range_from_mask_eq): New.
1323         (ASSERT_NO_BIT_RANGE_FROM_MASK): New macro.
1324         (selftest::test_bit_range_from_mask): New selftest.
1325         (selftest::analyzer_store_cc_tests): Call the new selftests.
1326         * store.h (bit_range::intersects_p): New.
1327         (bit_range::from_mask): New decl.
1328         (concrete_binding::get_bit_range): New accessor.
1329         (store_manager::get_concrete_binding): New overload taking
1330         const bit_range &.
1332 2021-06-08  David Malcolm  <dmalcolm@redhat.com>
1334         * analyzer.h (int_size_in_bits): New decl.
1335         * region.cc (int_size_in_bits): New function.
1336         (region::get_bit_size): Reimplement in terms of the above.
1338 2021-06-08  David Malcolm  <dmalcolm@redhat.com>
1340         * store.cc (concrete_binding::dump_to_pp): Move bulk of
1341         implementation to...
1342         (bit_range::dump_to_pp): ...this new function.
1343         (bit_range::cmp): New.
1344         (concrete_binding::overlaps_p): Update for use of bit_range.
1345         (concrete_binding::cmp_ptr_ptr): Likewise.
1346         * store.h (struct bit_range): New.
1347         (class concrete_binding): Replace fields m_start_bit_offset and
1348         m_size_in_bits with new field m_bit_range.
1350 2021-06-08  David Malcolm  <dmalcolm@redhat.com>
1352         * svalue.h (conjured_svalue::iterator_t): Delete.
1354 2021-06-03  David Malcolm  <dmalcolm@redhat.com>
1356         * store.h (store::get_direct_binding): Remove unused decl.
1357         (store::get_default_binding): Likewise.
1359 2021-06-03  David Malcolm  <dmalcolm@redhat.com>
1361         * svalue.cc (poisoned_svalue::dump_to_pp): Dump type.
1362         (compound_svalue::dump_to_pp): Dump any type.
1364 2021-05-18  David Malcolm  <dmalcolm@redhat.com>
1366         PR analyzer/100615
1367         * sm-malloc.cc: Include "analyzer/function-set.h".
1368         (malloc_state_machine::on_stmt): Call unaffected_by_call_p and
1369         bail on the functions it recognizes.
1370         (malloc_state_machine::unaffected_by_call_p): New.
1372 2021-05-10  Martin Liska  <mliska@suse.cz>
1374         * sm-file.cc (is_file_using_fn_p): Use startswith
1375         function instead of strncmp.
1377 2021-05-10  Martin Liska  <mliska@suse.cz>
1379         * program-state.cc (program_state::operator=): Remove
1380         __cplusplus >= 201103.
1381         (program_state::program_state): Likewise.
1382         * program-state.h: Likewise.
1383         * region-model.h (class region_model): Remove dead code.
1385 2021-04-24  David Malcolm  <dmalcolm@redhat.com>
1387         PR analyzer/100244
1388         * sm-malloc.cc (free_of_non_heap::describe_state_change):
1389         Bulletproof against change.m_expr being NULL.
1391 2021-04-13  David Malcolm  <dmalcolm@redhat.com>
1393         PR analyzer/98599
1394         * supergraph.cc (saved_uids::make_uid_unique): New.
1395         (saved_uids::restore_uids): New.
1396         (supergraph::supergraph): Replace assignments to stmt->uid with
1397         calls to m_stmt_uids.make_uid_unique.
1398         (supergraph::~supergraph): New.
1399         * supergraph.h (class saved_uids): New.
1400         (supergraph::~supergraph): New decl.
1401         (supergraph::m_stmt_uids): New field.
1403 2021-04-10  David Malcolm  <dmalcolm@redhat.com>
1405         PR analyzer/100011
1406         * region-model.cc (region_model::on_assignment): Avoid NULL
1407         dereference if ctxt is NULL when assigning from a STRING_CST.
1409 2021-04-08  David Malcolm  <dmalcolm@redhat.com>
1411         PR analyzer/99042
1412         PR analyzer/99774
1413         * engine.cc
1414         (impl_region_model_context::impl_region_model_context): Add
1415         uncertainty param and use it to initialize m_uncertainty.
1416         (impl_region_model_context::get_uncertainty): New.
1417         (impl_sm_context::get_fndecl_for_call): Add NULL for new
1418         uncertainty param when constructing impl_region_model_context.
1419         (impl_sm_context::get_state): Likewise.
1420         (impl_sm_context::set_next_state): Likewise.
1421         (impl_sm_context::warn): Likewise.
1422         (exploded_node::on_stmt): Add uncertainty param
1423         and use it when constructing impl_region_model_context.
1424         (exploded_node::on_edge): Add uncertainty param and pass
1425         to on_edge call.
1426         (exploded_node::detect_leaks): Create uncertainty_t and pass to
1427         impl_region_model_context.
1428         (exploded_graph::get_or_create_node): Create uncertainty_t and
1429         pass to prune_for_point.
1430         (maybe_process_run_of_before_supernode_enodes): Create
1431         uncertainty_t and pass to impl_region_model_context.
1432         (exploded_graph::process_node): Create uncertainty_t instances and
1433         pass around as needed.
1434         * exploded-graph.h
1435         (impl_region_model_context::impl_region_model_context): Add
1436         uncertainty param.
1437         (impl_region_model_context::get_uncertainty): New decl.
1438         (impl_region_model_context::m_uncertainty): New field.
1439         (exploded_node::on_stmt): Add uncertainty param.
1440         (exploded_node::on_edge): Likewise.
1441         * program-state.cc (sm_state_map::on_liveness_change): Get
1442         uncertainty from context and use it to unset sm-state from
1443         svalues as appropriate.
1444         (program_state::on_edge): Add uncertainty param and use it when
1445         constructing impl_region_model_context.  Fix indentation.
1446         (program_state::prune_for_point): Add uncertainty param and use it
1447         when constructing impl_region_model_context.
1448         (program_state::detect_leaks): Get any uncertainty from ctxt and
1449         use it to get maybe-live svalues for dest_state, rather than
1450         definitely-live ones; use this when determining which svalues
1451         have leaked.
1452         (selftest::test_program_state_merging): Create uncertainty_t and
1453         pass to impl_region_model_context.
1454         * program-state.h (program_state::on_edge): Add uncertainty param.
1455         (program_state::prune_for_point): Likewise.
1456         * region-model-impl-calls.cc (call_details::get_uncertainty): New.
1457         (region_model::impl_call_memcpy): Pass uncertainty to
1458         mark_region_as_unknown call.
1459         (region_model::impl_call_memset): Likewise.
1460         (region_model::impl_call_strcpy): Likewise.
1461         * region-model-reachability.cc (reachable_regions::handle_sval):
1462         Also add sval to m_mutable_svals.
1463         * region-model.cc (region_model::on_assignment): Pass any
1464         uncertainty from ctxt to the store::set_value call.
1465         (region_model::handle_unrecognized_call): Get any uncertainty from
1466         ctxt and use it to record mutable svalues at the unknown call.
1467         (region_model::get_reachable_svalues): Add uncertainty param and
1468         use it to mark any maybe-bound svalues as being reachable.
1469         (region_model::set_value): Pass any uncertainty from ctxt to the
1470         store::set_value call.
1471         (region_model::mark_region_as_unknown): Add uncertainty param and
1472         pass it on to the store::mark_region_as_unknown call.
1473         (region_model::update_for_call_summary): Add uncertainty param and
1474         pass it on to the region_model::mark_region_as_unknown call.
1475         * region-model.h (call_details::get_uncertainty): New decl.
1476         (region_model::get_reachable_svalues): Add uncertainty param.
1477         (region_model::mark_region_as_unknown): Add uncertainty param.
1478         (region_model_context::get_uncertainty): New vfunc.
1479         (noop_region_model_context::get_uncertainty): New vfunc
1480         implementation.
1481         * store.cc (dump_svalue_set): New.
1482         (uncertainty_t::dump_to_pp): New.
1483         (uncertainty_t::dump): New.
1484         (binding_cluster::clobber_region): Pass NULL for uncertainty to
1485         remove_overlapping_bindings.
1486         (binding_cluster::mark_region_as_unknown): Add uncertainty param
1487         and pass it to remove_overlapping_bindings.
1488         (binding_cluster::remove_overlapping_bindings): Add uncertainty param.
1489         Use it to record any svalues that were in clobbered bindings.
1490         (store::set_value): Add uncertainty param.  Pass it to
1491         binding_cluster::mark_region_as_unknown when handling symbolic
1492         regions.
1493         (store::mark_region_as_unknown): Add uncertainty param and pass it
1494         to binding_cluster::mark_region_as_unknown.
1495         (store::remove_overlapping_bindings): Add uncertainty param and
1496         pass it to binding_cluster::remove_overlapping_bindings.
1497         * store.h (binding_cluster::mark_region_as_unknown): Add
1498         uncertainty param.
1499         (binding_cluster::remove_overlapping_bindings): Likewise.
1500         (store::set_value): Likewise.
1501         (store::mark_region_as_unknown): Likewise.
1503 2021-04-05  David Malcolm  <dmalcolm@redhat.com>
1505         PR analyzer/99906
1506         * analyzer.cc (maybe_reconstruct_from_def_stmt): Fix NULL
1507         dereference on calls with zero arguments.
1508         * sm-malloc.cc (malloc_state_machine::on_stmt): When handling
1509         __attribute__((nonnull)), only call get_diagnostic_tree if the
1510         result will be used.
1512 2021-04-05  David Malcolm  <dmalcolm@redhat.com>
1514         PR analyzer/99886
1515         * diagnostic-manager.cc
1516         (diagnostic_manager::prune_interproc_events): Use signed integers
1517         when subtracting one from path->num_events ().
1518         (diagnostic_manager::consolidate_conditions): Likewise.  Convert
1519         next_idx to a signed int.
1521 2021-04-01  David Malcolm  <dmalcolm@redhat.com>
1523         * diagnostic-manager.cc (diagnostic_manager::add_diagnostic): Make
1524         enode param non-constant, and call add_diagnostic on it.  Add
1525         enode index to log message.
1526         (diagnostic_manager::add_diagnostic): Make enode param
1527         non-constant.
1528         * diagnostic-manager.h (diagnostic_manager::add_diagnostic):
1529         Likewise for both decls.
1530         * engine.cc
1531         (impl_region_model_context::impl_region_model_context): Likewise
1532         for enode_for_diag.
1533         (impl_sm_context::impl_sm_context): Likewise.
1534         (impl_sm_context::m_enode_for_diag): Likewise.
1535         (exploded_node::dump_dot): Don't pass the diagnostic manager
1536         to dump_saved_diagnostics.
1537         (exploded_node::dump_saved_diagnostics): Drop param.  Iterate
1538         directly through all saved diagnostics for the enode, rather
1539         than all saved diagnostics in the diagnostic_manager and
1540         filtering.
1541         (exploded_node::on_stmt): Make non-const.
1542         (exploded_node::on_edge): Likewise.
1543         (exploded_node::on_longjmp): Likewise.
1544         (exploded_node::detect_leaks): Likewise.
1545         (exploded_graph::get_or_create_node): Make enode_for_diag param
1546         non-const.
1547         (exploded_graph_annotator::print_enode): Iterate
1548         directly through all saved diagnostics for the enode, rather
1549         than all saved diagnostics in the diagnostic_manager and
1550         filtering.
1551         * exploded-graph.h
1552         (impl_region_model_context::impl_region_model_context): Make
1553         enode_for_diag param non-constant.
1554         (impl_region_model_context::m_enode_for_diag): Likewise.
1555         (exploded_node::dump_saved_diagnostics): Drop param.
1556         (exploded_node::on_stmt): Make non-const.
1557         (exploded_node::on_edge): Likewise.
1558         (exploded_node::on_longjmp): Likewise.
1559         (exploded_node::detect_leaks): Likewise.
1560         (exploded_node::add_diagnostic): New.
1561         (exploded_node::get_num_diagnostics): New.
1562         (exploded_node::get_saved_diagnostic): New.
1563         (exploded_node::m_saved_diagnostics): New.
1564         (exploded_graph::get_or_create_node): Make enode_for_diag param
1565         non-constant.
1566         * feasible-graph.cc (feasible_node::dump_dot): Drop
1567         diagnostic_manager from call to dump_saved_diagnostics.
1568         * program-state.cc (program_state::on_edge): Convert enode param
1569         to non-const pointer.
1570         (program_state::prune_for_point): Likewise for enode_for_diag
1571         param.
1572         * program-state.h (program_state::on_edge): Convert enode param
1573         to non-const pointer.
1574         (program_state::prune_for_point): Likewise for enode_for_diag
1575         param.
1577 2021-03-31  David Malcolm  <dmalcolm@redhat.com>
1579         PR analyzer/99771
1580         * analyzer.cc (maybe_reconstruct_from_def_stmt): New.
1581         (fixup_tree_for_diagnostic_1): New.
1582         (fixup_tree_for_diagnostic): New.
1583         * analyzer.h (fixup_tree_for_diagnostic): New decl.
1584         * checker-path.cc (call_event::get_desc): Call
1585         fixup_tree_for_diagnostic and use it for the call_with_state call.
1586         (warning_event::get_desc): Likewise for the final_event and
1587         make_label_text calls.
1588         * engine.cc (impl_region_model_context::on_state_leak): Likewise
1589         for the on_leak and add_diagnostic calls.
1590         * region-model.cc (region_model::get_representative_tree):
1591         Likewise for the result.
1593 2021-03-30  David Malcolm  <dmalcolm@redhat.com>
1595         * region.h (region::dump_to_pp): Remove old decl.
1597 2021-03-30  David Malcolm  <dmalcolm@redhat.com>
1599         * sm-file.cc (fileptr_state_machine::on_stmt): Only call
1600         get_diagnostic_tree if the result will be used.
1601         * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise.
1602         (malloc_state_machine::on_deallocator_call): Likewise.
1603         (malloc_state_machine::on_realloc_call): Likewise.
1604         (malloc_state_machine::on_realloc_call): Likewise.
1605         * sm-sensitive.cc
1606         (sensitive_state_machine::warn_for_any_exposure): Likewise.
1607         * sm-taint.cc (taint_state_machine::on_stmt): Likewise.
1609 2021-03-25  David Malcolm  <dmalcolm@redhat.com>
1611         PR analyzer/93695
1612         PR analyzer/99044
1613         PR analyzer/99716
1614         * engine.cc (exploded_node::on_stmt): Clear sm-state involving
1615         an SSA name at the def-stmt of that SSA name.
1616         * program-state.cc (sm_state_map::purge_state_involving): New.
1617         * program-state.h (sm_state_map::purge_state_involving): New decl.
1618         * region-model.cc (selftest::test_involves_p): New.
1619         (selftest::analyzer_region_model_cc_tests): Call it.
1620         * svalue.cc (class involvement_visitor): New class
1621         (svalue::involves_p): New.
1622         * svalue.h (svalue::involves_p): New decl.
1624 2021-03-19  David Malcolm  <dmalcolm@redhat.com>
1626         PR analyzer/99614
1627         * diagnostic-manager.cc (class epath_finder): Add
1628         DISABLE_COPY_AND_ASSIGN.
1630 2021-03-15  Martin Liska  <mliska@suse.cz>
1632         * sm-file.cc (get_file_using_fns): Add missing comma in initializer.
1634 2021-03-11  David Malcolm  <dmalcolm@redhat.com>
1636         PR analyzer/96374
1637         * analyzer.opt (-param=analyzer-max-infeasible-edges=): New param.
1638         (fdump-analyzer-feasibility): New flag.
1639         * diagnostic-manager.cc: Include "analyzer/trimmed-graph.h" and
1640         "analyzer/feasible-graph.h".
1641         (epath_finder::epath_finder): Convert m_sep to a pointer and
1642         only create it if !flag_analyzer_feasibility.
1643         (epath_finder::~epath_finder): New.
1644         (epath_finder::m_sep): Convert to a pointer.
1645         (epath_finder::get_best_epath): Add param "diag_idx" and use it
1646         when logging.  Rather than finding the shortest path and then
1647         checking feasibility, instead use explore_feasible_paths unless
1648         !flag_analyzer_feasibility, in which case simply use the shortest
1649         path, and note if it is infeasible.  Update for m_sep becoming a
1650         pointer.
1651         (class feasible_worklist): New.
1652         (epath_finder::explore_feasible_paths): New.
1653         (epath_finder::process_worklist_item): New.
1654         (class dump_eg_with_shortest_path): New.
1655         (epath_finder::dump_trimmed_graph): New.
1656         (epath_finder::dump_feasible_graph): New.
1657         (saved_diagnostic::saved_diagnostic): Add "idx" param, using it
1658         on new field m_idx.
1659         (saved_diagnostic::to_json): Dump m_idx.
1660         (saved_diagnostic::calc_best_epath): Pass m_idx to get_best_epath.
1661         Remove assertion that m_problem was set when m_best_epath is NULL.
1662         (diagnostic_manager::add_diagnostic): Pass an index when created
1663         saved_diagnostic instances.
1664         * diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Add
1665         "idx" param.
1666         (saved_diagnostic::get_index): New accessor.
1667         (saved_diagnostic::m_idx): New field.
1668         * engine.cc (exploded_node::dump_dot): Call args.dump_extra_info.
1669         Move code to...
1670         (exploded_node::dump_processed_stmts): ...this new function and...
1671         (exploded_node::dump_saved_diagnostics): ...this new function.
1672         Add index of each diagnostic.
1673         (exploded_edge::dump_dot):  Move bulk of code to...
1674         (exploded_edge::dump_dot_label): ...this new function.
1675         * exploded-graph.h (eg_traits::dump_args_t::dump_extra_info): New
1676         vfunc.
1677         (exploded_node::dump_processed_stmts): New decl.
1678         (exploded_node::dump_saved_diagnostics): New decl.
1679         (exploded_edge::dump_dot_label): New decl.
1680         * feasible-graph.cc: New file.
1681         * feasible-graph.h: New file.
1682         * trimmed-graph.cc: New file.
1683         * trimmed-graph.h: New file.
1685 2021-03-11  David Malcolm  <dmalcolm@redhat.com>
1687         * diagnostic-manager.cc (epath_finder::epath_finder):
1688         Update shortest_paths init for new param.
1690 2021-03-10  David Malcolm  <dmalcolm@redhat.com>
1692         PR analyzer/96374
1693         * engine.cc (exploded_path::feasible_p): Move "snodes_visited" and
1694         "model" locals into a new class feasibility_state.  Move heart
1695         of per-edge processing into
1696         feasibility_state::maybe_update_for_edge.
1697         (feasibility_state::feasibility_state): New.
1698         (feasibility_state::maybe_update_for_edge): New, based on loop
1699         body in exploded_path::feasible_p.
1700         * exploded-graph.h (class feasibility_state): New.
1702 2021-03-10  David Malcolm  <dmalcolm@redhat.com>
1704         * supergraph.h
1705         (callgraph_superedge::dyn_cast_callgraph_superedge): New.
1706         (call_superedge::dyn_cast_callgraph_superedge): Delete.
1707         (return_superedge::dyn_cast_callgraph_superedge): Delete.
1709 2021-03-02  Martin Liska  <mliska@suse.cz>
1711         * diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostics):
1712         Do not pass engine.
1714 2021-02-26  David Malcolm  <dmalcolm@redhat.com>
1716         * engine.cc (exploded_path::exploded_path): New copy-ctor.
1717         * exploded-graph.h (exploded_path::operator=): Drop decl.
1719 2021-02-26  David Malcolm  <dmalcolm@redhat.com>
1721         PR analyzer/96374
1722         * diagnostic-manager.cc (class epath_finder): New.
1723         (epath_finder::get_best_epath): New.
1724         (saved_diagnostic::saved_diagnostic): Update for replacement of
1725         m_state and m_epath_length with m_best_epath.
1726         (saved_diagnostic::~saved_diagnostic): Delete m_best_epath.
1727         (saved_diagnostic::to_json): Update "path_length" to be optional.
1728         (saved_diagnostic::calc_best_epath): New, based on
1729         dedupe_winners::add and parts of dedupe_key::dedupe_key.
1730         (saved_diagnostic::get_epath_length): New.
1731         (saved_diagnostic::add_duplicate): New.
1732         (dedupe_key::dedupe_key): Drop epath param.  Move invocation of
1733         stmt_finder to saved_diagnostic::calc_best_epath.
1734         (class dedupe_candidate): Delete.
1735         (class dedupe_hash_map_traits): Update to use saved_diagnotic *
1736         rather than dedupe_candidate * as the value_type/compare_type.
1737         (dedupe_winners::~dedupe_winners): Don't delete the values.
1738         (dedupe_winners::add): Convert param from shortest_exploded_paths to
1739         epath_finder.  Drop "eg" param.  Drop dedupe_candidate, moving
1740         path generation and feasiblity checking to
1741         epath_finder::get_best_epath.  Update winner-selection for move
1742         of epaths from dedupe_candidate to saved_diagnostic.
1743         (dedupe_winners::emit_best):  Update for removal of class
1744         dedupe_candidate.
1745         (dedupe_winners::map_t): Update to use saved_diagnotic * rather
1746         than dedupe_candidate * as the value_type/compare_type.
1747         (diagnostic_manager::emit_saved_diagnostics): Move
1748         shortest_exploded_paths instance into epath_finder and pass that
1749         around instead.
1750         (diagnostic_manager::emit_saved_diagnostic): Drop epath, stmt
1751         and num_dupes params, instead getting these from the
1752         saved_diagnostic.  Use correct location in inform_n call.
1753         * diagnostic-manager.h (class epath_finder): New forward decl.
1754         (saved_diagnostic::status): Drop enum.
1755         (saved_diagnostic::set_feasible): Drop.
1756         (saved_diagnostic::set_infeasible): Drop.
1757         (saved_diagnostic::get_status): Drop.
1758         (saved_diagnostic::calc_best_epath): New decl.
1759         (saved_diagnostic::get_best_epath): New decl.
1760         (saved_diagnostic::get_epath_length): New decl.
1761         (saved_diagnostic::set_epath_length): Drop.
1762         (saved_diagnostic::get_epath_length): Drop inline implementation.
1763         (saved_diagnostic::add_duplicate): New.
1764         (saved_diagnostic::get_num_dupes): New.
1765         (saved_diagnostic::m_d): Document ownership.
1766         (saved_diagnostic::m_trailing_eedge): Make const.
1767         (saved_diagnostic::m_status): Drop field.
1768         (saved_diagnostic::m_epath_length): Drop field.
1769         (saved_diagnostic::m_best_epath): New field.
1770         (saved_diagnostic::m_problem): Document ownership.
1771         (saved_diagnostic::m_duplicates): New field.
1772         (diagnostic_manager::emit_saved_diagnostic): Drop params epath,
1773         stmt, and num_dupes.
1774         * engine.cc (exploded_graph_annotator::print_saved_diagnostic):
1775         Update for changes to saved_diagnostic class.
1776         * exploded-graph.h (exploded_path::feasible_p): Drop unused
1777         overloaded decl.
1779 2021-02-25  David Malcolm  <dmalcolm@redhat.com>
1781         PR analyzer/99193
1782         * region-model-impl-calls.cc (region_model::impl_call_realloc): New.
1783         * region-model.cc (region_model::on_call_pre): Call it.
1784         * region-model.h (region_model::impl_call_realloc): New decl.
1785         * sm-malloc.cc (enum wording): Add WORDING_REALLOCATED.
1786         (malloc_state_machine::m_realloc): New field.
1787         (use_after_free::describe_state_change): Add case for
1788         WORDING_REALLOCATED.
1789         (use_after_free::describe_final_event): Likewise.
1790         (malloc_state_machine::malloc_state_machine): Initialize
1791         m_realloc.
1792         (malloc_state_machine::on_stmt): Handle realloc by calling...
1793         (malloc_state_machine::on_realloc_call): New.
1795 2021-02-22  David Malcolm  <dmalcolm@redhat.com>
1797         PR analyzer/99196
1798         * engine.cc (exploded_node::on_stmt): Provide terminate_path
1799         flag as a way for on_call_pre to terminate the current analysis
1800         path.
1801         * region-model-impl-calls.cc (call_details::num_args): New.
1802         (region_model::impl_call_error): New.
1803         * region-model.cc (region_model::on_call_pre): Add param
1804         "out_terminate_path".  Handle "error" and "error_at_line".
1805         * region-model.h (call_details::num_args): New decl.
1806         (region_model::on_call_pre): Add param "out_terminate_path".
1807         (region_model::impl_call_error): New decl.
1809 2021-02-17  David Malcolm  <dmalcolm@redhat.com>
1811         PR analyzer/98969
1812         * constraint-manager.cc (dead_svalue_purger::should_purge_p):
1813         Update for change to svalue::live_p.
1814         * program-state.cc (sm_state_map::on_liveness_change): Likewise.
1815         (program_state::detect_leaks): Likewise.
1816         * region-model-reachability.cc (reachable_regions::init_cluster):
1817         When dealing with a symbolic region, if the underlying pointer is
1818         implicitly live, add the region to the reachable regions.
1819         * region-model.cc (region_model::compare_initial_and_pointer):
1820         Move logic for detecting initial values of params to
1821         initial_svalue::initial_value_of_param_p.
1822         * svalue.cc (svalue::live_p): Convert "live_svalues" from a
1823         reference to a pointer; support it being NULL.
1824         (svalue::implicitly_live_p): Convert first param from a
1825         refererence to a pointer.
1826         (region_svalue::implicitly_live_p): Likewise.
1827         (constant_svalue::implicitly_live_p): Likewise.
1828         (initial_svalue::implicitly_live_p): Likewise.  Treat the initial
1829         values of params for the top level frame as still live.
1830         (initial_svalue::initial_value_of_param_p): New function, taken
1831         from a test in region_model::compare_initial_and_pointer.
1832         (unaryop_svalue::implicitly_live_p): Convert first param from a
1833         refererence to a pointer.
1834         (binop_svalue::implicitly_live_p): Likewise.
1835         (sub_svalue::implicitly_live_p): Likewise.
1836         (unmergeable_svalue::implicitly_live_p): Likewise.
1837         * svalue.h (svalue::live_p): Likewise.
1838         (svalue::implicitly_live_p): Likewise.
1839         (region_svalue::implicitly_live_p): Likewise.
1840         (constant_svalue::implicitly_live_p): Likewise.
1841         (initial_svalue::implicitly_live_p): Likewise.
1842         (initial_svalue::initial_value_of_param_p): New decl.
1843         (unaryop_svalue::implicitly_live_p): Convert first param from a
1844         refererence to a pointer.
1845         (binop_svalue::implicitly_live_p): Likewise.
1846         (sub_svalue::implicitly_live_p): Likewise.
1847         (unmergeable_svalue::implicitly_live_p): Likewise.
1849 2021-02-12  David Malcolm  <dmalcolm@redhat.com>
1851         PR analyzer/98969
1852         * engine.cc (readability): Add names for the various arbitrary
1853         values.  Handle NOP_EXPR and INTEGER_CST.
1854         (readability_comparator): Combine the readability tests for
1855         tree and stack depth, rather than performing them sequentially.
1856         (impl_region_model_context::on_state_leak): Strip off top-level
1857         casts.
1858         * region-model.cc (region_model::get_representative_path_var): Add
1859         type-checking, moving the bulk of the implementation to...
1860         (region_model::get_representative_path_var_1): ...here.  Respect
1861         types in casts by recursing and re-adding the cast, rather than
1862         merely stripping them off.  Use the correct type when handling
1863         region_svalue.
1864         (region_model::get_representative_tree): Strip off any top-level
1865         cast.
1866         (region_model::get_representative_path_var): Add type-checking,
1867         moving the bulk of the implementation to...
1868         (region_model::get_representative_path_var_1): ...here.
1869         * region-model.h (region_model::get_representative_path_var_1):
1870         New decl
1871         (region_model::get_representative_path_var_1): New decl.
1872         * store.cc (append_pathvar_with_type): New.
1873         (binding_cluster::get_representative_path_vars): Cast path_vars
1874         to the correct type when adding them to *OUT_PVS.
1876 2021-02-09  David Malcolm  <dmalcolm@redhat.com>
1878         PR analyzer/98575
1879         * sm-file.cc (is_file_using_fn_p): Support "_IO_"-prefixed
1880         variants.
1882 2021-02-09  David Malcolm  <dmalcolm@redhat.com>
1884         PR analyzer/98575
1885         * store.cc (store::set_value): Treat a pointer written to *UNKNOWN
1886         as having escaped.
1888 2021-02-02  David Malcolm  <dmalcolm@redhat.com>
1890         PR analyzer/93355
1891         PR analyzer/96374
1892         * engine.cc (toplevel_function_p): Simplify so that
1893         we only reject functions with a "__analyzer_" prefix.
1894         (add_any_callbacks): Delete.
1895         (exploded_graph::build_initial_worklist): Update for
1896         dropped param of toplevel_function_p.
1897         (exploded_graph::build_initial_worklist): Don't bother
1898         looking for callbacks that are reachable from global
1899         initializers.
1901 2021-02-01  David Malcolm  <dmalcolm@redhat.com>
1903         PR analyzer/98918
1904         * region-model-manager.cc
1905         (region_model_manager::get_or_create_initial_value):
1906         Fold the initial value of *UNKNOWN_PTR to an UNKNOWN value.
1907         (region_model_manager::get_field_region): Fold the value
1908         of UNKNOWN_PTR->FIELD to *UNKNOWN_PTR_OF_&FIELD_TYPE.
1910 2021-01-29  David Malcolm  <dmalcolm@redhat.com>
1912         * checker-path.cc (event_kind_to_string): Handle
1913         EK_START_CONSOLIDATED_CFG_EDGES and
1914         EK_END_CONSOLIDATED_CFG_EDGES.
1915         (start_consolidated_cfg_edges_event::get_desc): New.
1916         (checker_path::cfg_edge_pair_at_p): New.
1917         * checker-path.h (enum event_kind): Add
1918         EK_START_CONSOLIDATED_CFG_EDGES and
1919         EK_END_CONSOLIDATED_CFG_EDGES.
1920         (class start_consolidated_cfg_edges_event): New class.
1921         (class end_consolidated_cfg_edges_event): New class.
1922         (checker_path::delete_events): New.
1923         (checker_path::replace_event): New.
1924         (checker_path::cfg_edge_pair_at_p): New decl.
1925         * diagnostic-manager.cc (diagnostic_manager::prune_path): Call
1926         consolidate_conditions.
1927         (same_line_as_p): New.
1928         (diagnostic_manager::consolidate_conditions): New.
1929         * diagnostic-manager.h
1930         (diagnostic_manager::consolidate_conditions): New decl.
1932 2021-01-18  David Malcolm  <dmalcolm@redhat.com>
1934         * analyzer.h (is_std_named_call_p): New decl.
1935         * diagnostic-manager.cc (path_builder::get_sm): New.
1936         (state_change_event_creator::state_change_event_creator): Add "pb"
1937         param.
1938         (state_change_event_creator::on_global_state_change): Don't consider
1939         state changes affecting other state_machines.
1940         (state_change_event_creator::on_state_change): Likewise.
1941         (state_change_event_creator::m_pb): New field.
1942         (diagnostic_manager::add_events_for_eedge): Pass pb to visitor
1943         ctor.
1944         * region-model-impl-calls.cc
1945         (region_model::impl_deallocation_call): New.
1946         * region-model.cc: Include "attribs.h".
1947         (region_model::on_call_post): Handle fndecls referenced by
1948         __attribute__((deallocated_by(FOO))).
1949         * region-model.h (region_model::impl_deallocation_call): New decl.
1950         * sm-malloc.cc: Include "stringpool.h" and "attribs.h".  Add
1951         leading comment.
1952         (class api): Delete.
1953         (enum resource_state): Update comment for change from api to
1954         deallocator and deallocator_set.
1955         (allocation_state::allocation_state): Drop api param.  Add
1956         "deallocators" and "deallocator".
1957         (allocation_state::m_api): Drop field in favor of...
1958         (allocation_state::m_deallocators): New field.
1959         (allocation_state::m_deallocator): New field.
1960         (enum wording): Add WORDING_DEALLOCATED.
1961         (struct deallocator): New.
1962         (struct standard_deallocator): New.
1963         (struct custom_deallocator): New.
1964         (struct deallocator_set): New.
1965         (struct custom_deallocator_set): New.
1966         (struct standard_deallocator_set): New.
1967         (struct deallocator_set_map_traits): New.
1968         (malloc_state_machine::m_malloc): Drop field
1969         (malloc_state_machine::m_scalar_new): Likewise.
1970         (malloc_state_machine::m_vector_new): Likewise.
1971         (malloc_state_machine::m_free): New field
1972         (malloc_state_machine::m_scalar_delete): Likewise.
1973         (malloc_state_machine::m_vector_delete): Likewise.
1974         (malloc_state_machine::deallocator_map_t): New typedef.
1975         (malloc_state_machine::m_deallocator_map): New field.
1976         (malloc_state_machine::deallocator_set_cache_t): New typedef.
1977         (malloc_state_machine::m_custom_deallocator_set_cache): New field.
1978         (malloc_state_machine::custom_deallocator_set_map_t): New typedef.
1979         (malloc_state_machine::m_custom_deallocator_set_map): New field.
1980         (malloc_state_machine::m_dynamic_sets): New field.
1981         (malloc_state_machine::m_dynamic_deallocators): New field.
1982         (api::api): Delete.
1983         (deallocator::deallocator): New ctor.
1984         (deallocator::hash): New.
1985         (deallocator::dump_to_pp): New.
1986         (deallocator::cmp): New.
1987         (deallocator::cmp_ptr_ptr): New.
1988         (standard_deallocator::standard_deallocator): New ctor.
1989         (deallocator_set::deallocator_set): New ctor.
1990         (deallocator_set::dump): New.
1991         (custom_deallocator_set::custom_deallocator_set): New ctor.
1992         (custom_deallocator_set::contains_p): New.
1993         (custom_deallocator_set::maybe_get_single): New.
1994         (custom_deallocator_set::dump_to_pp): New.
1995         (standard_deallocator_set::standard_deallocator_set): New ctor.
1996         (standard_deallocator_set::contains_p): New.
1997         (standard_deallocator_set::maybe_get_single): New.
1998         (standard_deallocator_set::dump_to_pp): New.
1999         (start_p): New.
2000         (class mismatching_deallocation): Update for conversion from api
2001         to deallocator_set and deallocator.
2002         (double_free::emit): Use %qs.
2003         (class use_after_free): Update for conversion from api to
2004         deallocator_set and deallocator.
2005         (malloc_leak::describe_state_change): Only emit "allocated here" on
2006         a start->nonnull transition, rather than on other transitions to
2007         nonnull.
2008         (allocation_state::dump_to_pp): Update for conversion from api to
2009         deallocator_set.
2010         (allocation_state::get_nonnull): Likewise.
2011         (malloc_state_machine::malloc_state_machine): Likewise.
2012         (malloc_state_machine::~malloc_state_machine): New.
2013         (malloc_state_machine::add_state): Update for conversion from api
2014         to deallocator_set.
2015         (malloc_state_machine::get_or_create_custom_deallocator_set): New.
2016         (malloc_state_machine::maybe_create_custom_deallocator_set): New.
2017         (malloc_state_machine::get_or_create_deallocator): New.
2018         (malloc_state_machine::on_stmt): Update for conversion from api
2019         to deallocator_set.  Handle "__attribute__((malloc(FOO)))", and
2020         the special attribute set on FOO.
2021         (malloc_state_machine::on_allocator_call): Update for conversion
2022         from api to deallocator_set.  Add "returns_nonnull" param and use
2023         it to affect which state to transition to.
2024         (malloc_state_machine::on_deallocator_call): Update for conversion
2025         from api to deallocator_set.
2027 2021-01-14  David Malcolm  <dmalcolm@redhat.com>
2029         * engine.cc (strongly_connected_components::to_json): New.
2030         (worklist::to_json): New.
2031         (exploded_graph::to_json): JSON-ify the worklist.
2032         * exploded-graph.h (strongly_connected_components::to_json): New
2033         decl.
2034         (worklist::to_json): New decl.
2035         * store.cc (store::to_json): Fix comment.
2036         * supergraph.cc (supernode::to_json): Fix reference to
2037         "returning_call" in comment.  Add optional "fun" to JSON.
2038         (edge_kind_to_string): New.
2039         (superedge::to_json): Add "kind" to JSON.
2041 2021-01-14  David Malcolm  <dmalcolm@redhat.com>
2043         PR analyzer/98679
2044         * analyzer.h (region_offset::operator==): Make const.
2045         * pending-diagnostic.h (pending_diagnostic::equal_p): Likewise.
2046         * store.h (binding_cluster::for_each_value): Likewise.
2047         (binding_cluster::for_each_binding): Likewise.
2049 2021-01-12  David Malcolm  <dmalcolm@redhat.com>
2051         PR analyzer/98628
2052         * store.cc (binding_cluster::make_unknown_relative_to): Don't mark
2053         dereferenced unknown pointers as having escaped.
2055 2021-01-07  David Malcolm  <dmalcolm@redhat.com>
2057         PR analyzer/98580
2058         * region.cc (decl_region::get_svalue_for_initializer): Gracefully
2059         handle when LTO writes out DECL_INITIAL as error_mark_node.
2061 2021-01-07  David Malcolm  <dmalcolm@redhat.com>
2063         PR analyzer/97074
2064         * store.cc (binding_cluster::can_merge_p): Add "out_store" param
2065         and pass to calls to binding_cluster::make_unknown_relative_to.
2066         (binding_cluster::make_unknown_relative_to): Add "out_store"
2067         param.  Use it to mark base regions that are pointed to by
2068         pointers that become unknown as having escaped.
2069         (store::can_merge_p): Pass out_store to
2070         binding_cluster::can_merge_p.
2071         * store.h (binding_cluster::can_merge_p): Add "out_store" param.
2072         (binding_cluster::make_unknown_relative_to): Likewise.
2073         * svalue.cc (region_svalue::implicitly_live_p): New vfunc.
2074         * svalue.h (region_svalue::implicitly_live_p): New vfunc decl.
2076 2021-01-07  David Malcolm  <dmalcolm@redhat.com>
2078         PR analyzer/98564
2079         * engine.cc (exploded_path::feasible_p): Add missing call to
2080         bitmap_clear.
2082 2021-01-06  David Malcolm  <dmalcolm@redhat.com>
2084         PR analyzer/97072
2085         * region-model-reachability.cc (reachable_regions::init_cluster):
2086         Convert symbolic region handling to a switch statement.  Add cases
2087         to handle SK_UNKNOWN and SK_CONJURED.
2089 2021-01-05  David Malcolm  <dmalcolm@redhat.com>
2091         PR analyzer/98293
2092         * store.cc (binding_map::apply_ctor_to_region): When "index" is
2093         NULL, iterate through the fields for RECORD_TYPEs, rather than
2094         creating an INTEGER_CST index.
2096 2020-11-30  David Malcolm  <dmalcolm@redhat.com>
2098         * analyzer-pass.cc: Include "analyzer/analyzer.h" for the
2099         declaration of sorry_no_analyzer; include "tree.h" and
2100         "function.h" as these are needed by it.
2102 2020-11-30  David Malcolm  <dmalcolm@redhat.com>
2104         * analyzer-pass.cc (pass_analyzer::execute): Move sorry call to...
2105         (sorry_no_analyzer): New.
2106         * analyzer.h (class state_machine): New forward decl.
2107         (class logger): New forward decl.
2108         (class plugin_analyzer_init_iface): New.
2109         (sorry_no_analyzer): New decl.
2110         * checker-path.cc (checker_path::fixup_locations): New.
2111         * checker-path.h (checker_event::set_location): New.
2112         (checker_path::fixup_locations): New decl.
2113         * diagnostic-manager.cc
2114         (diagnostic_manager::emit_saved_diagnostic): Call
2115         checker_path::fixup_locations, and call fixup_location
2116         on the primary location.
2117         * engine.cc: Include "plugin.h".
2118         (class plugin_analyzer_init_impl): New.
2119         (impl_run_checkers): Invoke PLUGIN_ANALYZER_INIT callbacks.
2120         * pending-diagnostic.h (pending_diagnostic::fixup_location): New
2121         vfunc.
2123 2020-11-18  David Malcolm  <dmalcolm@redhat.com>
2125         PR analyzer/97893
2126         * sm-malloc.cc (null_deref::emit): Use CWE-476 rather than
2127         CWE-690, as this isn't due to an unchecked return value.
2128         (null_arg::emit): Likewise.
2130 2020-11-12  David Malcolm  <dmalcolm@redhat.com>
2132         * checker-path.h (checker_event::get_id_ptr): New.
2133         * diagnostic-manager.cc (path_builder::path_builder): Add "sd"
2134         param and use it to initialize new field "m_sd".
2135         (path_builder::get_pending_diagnostic): New.
2136         (path_builder::m_sd): New field.
2137         (diagnostic_manager::emit_saved_diagnostic): Pass sd to
2138         path_builder ctor.
2139         (diagnostic_manager::add_events_for_superedge): Call new
2140         maybe_add_custom_events_for_superedge vfunc.
2141         * engine.cc (stale_jmp_buf::stale_jmp_buf): Add "setjmp_point"
2142         param and use it to initialize new field "m_setjmp_point".
2143         Initialize new field "m_stack_pop_event".
2144         (stale_jmp_buf::maybe_add_custom_events_for_superedge): New vfunc
2145         implementation.
2146         (stale_jmp_buf::describe_final_event): New vfunc implementation.
2147         (stale_jmp_buf::m_setjmp_point): New field.
2148         (stale_jmp_buf::m_stack_pop_event): New field.
2149         (exploded_node::on_longjmp): Pass setjmp_point to stale_jmp_buf
2150         ctor.
2151         * pending-diagnostic.h
2152         (pending_diagnostic::maybe_add_custom_events_for_superedge): New
2153         vfunc.
2155 2020-11-12  David Malcolm  <dmalcolm@redhat.com>
2157         PR tree-optimization/97424
2158         * analyzer.opt (Wanalyzer-shift-count-negative): New.
2159         (Wanalyzer-shift-count-overflow): New.
2160         * region-model.cc (class shift_count_negative_diagnostic): New.
2161         (class shift_count_overflow_diagnostic): New.
2162         (region_model::get_gassign_result): Complain about shift counts that
2163         are negative or are >= the operand's type's width.
2165 2020-11-10  Martin Liska  <mliska@suse.cz>
2167         * constraint-manager.cc (constraint_manager::merge): Remove
2168         unused code.
2169         * constraint-manager.h: Likewise.
2170         * program-state.cc (sm_state_map::sm_state_map): Likewise.
2171         (program_state::program_state): Likewise.
2172         (test_sm_state_map): Likewise.
2173         * program-state.h: Likewise.
2174         * region-model-reachability.cc (reachable_regions::reachable_regions): Likewise.
2175         * region-model-reachability.h: Likewise.
2176         * region-model.cc (region_model::handle_unrecognized_call): Likewise.
2177         (region_model::get_reachable_svalues): Likewise.
2178         (region_model::can_merge_with_p): Likewise.
2180 2020-11-05  David Malcolm  <dmalcolm@redhat.com>
2182         PR analyzer/97668
2183         * svalue.cc (cmp_cst): Handle COMPLEX_CST.
2185 2020-10-29  David Malcolm  <dmalcolm@redhat.com>
2187         * program-state.cc (sm_state_map::on_liveness_change): Sort the
2188         leaking svalues before calling on_state_leak.
2189         (program_state::detect_leaks): Likewise when calling
2190         on_svalue_leak.
2191         * region-model-reachability.cc
2192         (reachable_regions::mark_escaped_clusters): Likewise when
2193         calling on_escaped_function.
2195 2020-10-29  David Malcolm  <dmalcolm@redhat.com>
2197         PR analyzer/97608
2198         * region-model-reachability.cc (reachable_regions::handle_sval):
2199         Operands of reachable reversible operations are reachable.
2201 2020-10-29  David Malcolm  <dmalcolm@redhat.com>
2203         * analyzer.h (class state_machine): New forward decl.
2204         (class logger): Likewise.
2205         (class visitor): Likewise.
2206         * complexity.cc: New file, taken from svalue.cc.
2207         * complexity.h: New file, taken from region-model.h.
2208         * region-model.h: Include "analyzer/svalue.h" and
2209         "analyzer/region.h".  Move struct complexity to complexity.h.
2210         Move svalue, its subclasses and supporting decls to svalue.h.
2211         Move region, its subclasses and supporting decls to region.h.
2212         * region.cc: Include "analyzer/region.h".
2213         (symbolic_region::symbolic_region): Move here from region-model.h.
2214         * region.h: New file, based on material from region-model.h.
2215         * svalue.cc: Include "analyzer/svalue.h".
2216         (complexity::complexity): Move to complexity.cc.
2217         (complexity::from_pair): Likewise.
2218         * svalue.h: New file, based on material from region-model.h.
2220 2020-10-29  David Malcolm  <dmalcolm@redhat.com>
2222         * program-state.cc (sm_state_map::print): Guard the printing of
2223         the origin pointer with !flag_dump_noaddr.
2224         * region.cc (string_region::dump_to_pp): Likewise for
2225         m_string_cst.
2227 2020-10-27  David Malcolm  <dmalcolm@redhat.com>
2229         PR analyzer/97568
2230         * region-model.cc (region_model::get_initial_value_for_global):
2231         Move check that !DECL_EXTERNAL from here to...
2232         * region.cc (decl_region::get_svalue_for_initializer): ...here,
2233         using it to reject zero initialization.
2235 2020-10-27  Markus Böck  <markus.boeck02@gmail.com>
2237         PR analyzer/96608
2238         * store.h (hash): Cast to intptr_t instead of long
2240 2020-10-27  David Malcolm  <dmalcolm@redhat.com>
2242         * constraint-manager.cc (svalue_cmp_by_ptr): Delete.
2243         (equiv_class::canonicalize): Use svalue::cmp_ptr_ptr instead.
2244         (equiv_class_cmp): Eliminate pointer comparison.
2245         * diagnostic-manager.cc (dedupe_key::comparator): If they are at
2246         the same location, also compare epath ength and pending_diagnostic
2247         kind.
2248         * engine.cc (readability_comparator): If two path_vars have the
2249         same readability, then impose an arbitrary ordering on them.
2250         (worklist::key_t::cmp): If two points have the same plan ordering,
2251         continue the comparison.  Call sm_state_map::cmp rather than
2252         comparing hash values.
2253         * program-state.cc (sm_state_map::entry_t::cmp): New.
2254         (sm_state_map::cmp): New.
2255         * program-state.h (sm_state_map::entry_t::cmp): New decl.
2256         (sm_state_map::elements): New.
2257         (sm_state_map::cmp): New.
2259 2020-10-27  David Malcolm  <dmalcolm@redhat.com>
2261         * engine.cc (setjmp_record::cmp): New.
2262         (supernode_cluster::dump_dot): Avoid embedding pointer in cluster
2263         name.
2264         (supernode_cluster::cmp_ptr_ptr): New.
2265         (function_call_string_cluster::dump_dot): Avoid embedding pointer
2266         in cluster name.  Sort m_map when dumping child clusters.
2267         (function_call_string_cluster::cmp_ptr_ptr): New.
2268         (root_cluster::dump_dot): Sort m_map when dumping child clusters.
2269         * program-point.cc (function_point::cmp): New.
2270         (function_point::cmp_ptr): New.
2271         * program-point.h (function_point::cmp): New decl.
2272         (function_point::cmp_ptr): New decl.
2273         * program-state.cc (sm_state_map::print): Sort the values.  Guard
2274         the printing of pointers with !flag_dump_noaddr.
2275         (program_state::prune_for_point): Sort the regions.
2276         (log_set_of_svalues): Sort the values.  Guard the printing of
2277         pointers with !flag_dump_noaddr.
2278         * region-model-manager.cc (log_uniq_map): Sort the values.
2279         * region-model-reachability.cc (dump_set): New function template.
2280         (reachable_regions::dump_to_pp): Use it.
2281         * region-model.h (svalue::cmp_ptr): New decl.
2282         (svalue::cmp_ptr_ptr): New decl.
2283         (setjmp_record::cmp): New decl.
2284         (placeholder_svalue::get_name): New accessor.
2285         (widening_svalue::get_point): New accessor.
2286         (compound_svalue::get_map): New accessor.
2287         (conjured_svalue::get_stmt): New accessor.
2288         (conjured_svalue::get_id_region): New accessor.
2289         (region::cmp_ptrs): Rename to...
2290         (region::cmp_ptr_ptr): ...this.
2291         * region.cc (region::cmp_ptrs): Rename to...
2292         (region::cmp_ptr_ptr): ...this.
2293         * state-purge.cc
2294         (state_purge_per_ssa_name::state_purge_per_ssa_name): Sort
2295         m_points_needing_name when dumping.
2296         * store.cc (concrete_binding::cmp_ptr_ptr): New.
2297         (symbolic_binding::cmp_ptr_ptr): New.
2298         (binding_map::cmp): New.
2299         (get_sorted_parent_regions): Update for renaming of
2300         region::cmp_ptrs to region::cmp_ptr_ptr.
2301         (store::dump_to_pp): Likewise.
2302         (store::to_json): Likewise.
2303         (store::can_merge_p): Sort the base regions before considering
2304         them.
2305         * store.h (concrete_binding::cmp_ptr_ptr): New decl.
2306         (symbolic_binding::cmp_ptr_ptr): New decl.
2307         (binding_map::cmp): New decl.
2308         * supergraph.cc (supergraph::supergraph): Assign UIDs to the
2309         gimple stmts.
2310         * svalue.cc (cmp_cst): New.
2311         (svalue::cmp_ptr): New.
2312         (svalue::cmp_ptr_ptr): New.
2314 2020-10-27  David Malcolm  <dmalcolm@redhat.com>
2316         * engine.cc (exploded_graph::get_or_create_node): Fix off-by-one
2317         when imposing param_analyzer_max_enodes_per_program_point limit.
2319 2020-10-27  David Malcolm  <dmalcolm@redhat.com>
2321         * region-model.cc (region_model::get_representative_path_var):
2322         Implement case RK_LABEL.
2323         * region-model.h (label_region::get_label): New accessor.
2325 2020-10-22  David Malcolm  <dmalcolm@redhat.com>
2327         PR analyzer/97514
2328         * engine.cc (exploded_graph::add_function_entry): Handle failure
2329         to create an enode, rather than asserting.
2331 2020-10-22  David Malcolm  <dmalcolm@redhat.com>
2333         PR analyzer/97489
2334         * engine.cc (exploded_graph::add_function_entry): Assert that we
2335         have a function body.
2336         (exploded_graph::on_escaped_function): Reject fndecls that don't
2337         have a function body.
2339 2020-10-14  David Malcolm  <dmalcolm@redhat.com>
2341         PR analyzer/93388
2342         * region-model.cc (region_model::get_initial_value_for_global):
2343         Fall back to returning an initial_svalue if
2344         decl_region::get_svalue_for_initializer fails.
2345         * region.cc (decl_region::get_svalue_for_initializer): Don't
2346         attempt to create a compound_svalue if the region has an unknown
2347         size.
2349 2020-10-14  David Malcolm  <dmalcolm@redhat.com>
2351         PR analyzer/93723
2352         * store.cc (binding_map::apply_ctor_to_region): Remove redundant
2353         assertion.
2355 2020-10-12  David Malcolm  <dmalcolm@redhat.com>
2357         PR analyzer/97258
2358         * engine.cc (impl_region_model_context::on_escaped_function): New
2359         vfunc.
2360         (exploded_graph::add_function_entry): Use m_functions_with_enodes
2361         to implement idempotency.
2362         (add_any_callbacks): New.
2363         (exploded_graph::build_initial_worklist): Use the above to find
2364         callbacks that are reachable from global initializers.
2365         (exploded_graph::on_escaped_function): New.
2366         * exploded-graph.h
2367         (impl_region_model_context::on_escaped_function): New decl.
2368         (exploded_graph::on_escaped_function): New decl.
2369         (exploded_graph::m_functions_with_enodes): New field.
2370         * region-model-reachability.cc
2371         (reachable_regions::reachable_regions): Replace "store" param with
2372         "model" param; use it to initialize m_model.
2373         (reachable_regions::add): When getting the svalue for the region,
2374         call get_store_value on the model rather than using an initial
2375         value.
2376         (reachable_regions::mark_escaped_clusters): Add ctxt param and
2377         use it to call on_escaped_function when a function_region escapes.
2378         * region-model-reachability.h
2379         (reachable_regions::reachable_regions): Replace "store" param with
2380         "model" param.
2381         (reachable_regions::mark_escaped_clusters): Add ctxt param.
2382         (reachable_regions::m_model): New field.
2383         * region-model.cc (region_model::handle_unrecognized_call): Update
2384         for change in reachable_regions ctor.
2385         (region_model::handle_unrecognized_call): Pass ctxt to
2386         mark_escaped_clusters.
2387         (region_model::get_reachable_svalues): Update for change in
2388         reachable_regions ctor.
2389         (region_model::get_initial_value_for_global): Read-only variables
2390         keep their initial values.
2391         * region-model.h (region_model_context::on_escaped_function): New
2392         vfunc.
2393         (noop_region_model_context::on_escaped_function): New.
2395 2020-10-12  David Malcolm  <dmalcolm@redhat.com>
2397         * analyzer.opt (Wanalyzer-write-to-const): New.
2398         (Wanalyzer-write-to-string-literal): New.
2399         * region-model-impl-calls.cc (region_model::impl_call_memcpy):
2400         Call check_for_writable_region.
2401         (region_model::impl_call_memset): Likewise.
2402         (region_model::impl_call_strcpy): Likewise.
2403         * region-model.cc (class write_to_const_diagnostic): New.
2404         (class write_to_string_literal_diagnostic): New.
2405         (region_model::check_for_writable_region): New.
2406         (region_model::set_value): Call check_for_writable_region.
2407         * region-model.h (region_model::check_for_writable_region): New
2408         decl.
2410 2020-10-07  David Malcolm  <dmalcolm@redhat.com>
2412         PR analyzer/97116
2413         * sm-malloc.cc (method_p): New.
2414         (describe_argument_index): New.
2415         (inform_nonnull_attribute): Use describe_argument_index.
2416         (possible_null_arg::describe_final_event): Likewise.
2417         (null_arg::describe_final_event): Likewise.
2419 2020-09-29  David Malcolm  <dmalcolm@redhat.com>
2421         PR analyzer/95188
2422         * engine.cc (stmt_requires_new_enode_p): Split enodes before
2423         "signal" calls.
2425 2020-09-29  David Malcolm  <dmalcolm@redhat.com>
2427         * constraint-manager.cc
2428         (constraint_manager::add_constraint_internal): Whitespace fixes.
2429         Silence -Wsign-compare warning.
2430         * engine.cc (maybe_process_run_of_before_supernode_enodes):
2431         Silence -Wsign-compare warning.
2433 2020-09-28  David Malcolm  <dmalcolm@redhat.com>
2435         * region-model.h (binop_svalue::dyn_cast_binop_svalue): Remove
2436         redundant "virtual".  Add FINAL OVERRIDE.
2437         (widening_svalue::dyn_cast_widening_svalue): Add FINAL OVERRIDE.
2438         (compound_svalue::dyn_cast_compound_svalue): Likewise.
2439         (conjured_svalue::dyn_cast_conjured_svalue): Likewise.
2441 2020-09-28  David Malcolm  <dmalcolm@redhat.com>
2443         * diagnostic-manager.cc (null_assignment_sm_context::m_visitor):
2444         Remove unused field.
2446 2020-09-28  David Malcolm  <dmalcolm@redhat.com>
2448         PR analyzer/97233
2449         * analyzer.cc (is_longjmp_call_p): Require the initial argument
2450         to be a pointer.
2451         * engine.cc (exploded_node::on_longjmp): Likewise.
2453 2020-09-28  David Malcolm  <dmalcolm@redhat.com>
2455         * program-state.cc (sm_state_map::print): Update check
2456         for m_global_state being the start state.
2458 2020-09-26  David Malcolm  <dmalcolm@redhat.com>
2460         PR analyzer/96646
2461         PR analyzer/96841
2462         * region-model.cc (region_model::get_representative_path_var):
2463         When handling offset_region, wrap the MEM_REF's first argument in
2464         an ADDR_EXPR of pointer type, rather than simply using the tree
2465         for the parent region.  Require the MEM_REF's second argument to
2466         be an integer constant.
2468 2020-09-24  David Malcolm  <dmalcolm@redhat.com>
2470         * analyzer.h (struct rejected_constraint): New decl.
2471         * analyzer.opt (fanalyzer-feasibility): New option.
2472         * diagnostic-manager.cc (path_builder::path_builder): Add
2473         "problem" param and use it to initialize new field.
2474         (path_builder::get_feasibility_problem): New accessor.
2475         (path_builder::m_feasibility_problem): New field.
2476         (dedupe_winners::add): Remove inversion of logic in "if" clause,
2477         swapping if/else suites.  In the !feasible_p suite, inspect
2478         flag_analyzer_feasibility and add code to handle when this
2479         is off, accepting the infeasible path, but recording the
2480         feasibility_problem.
2481         (diagnostic_manager::emit_saved_diagnostic): Pass the
2482         feasibility_problem to the path_builder.
2483         (diagnostic_manager::add_events_for_eedge): If we have
2484         a feasibility_problem at this edge, use it to add a custom event.
2485         * engine.cc (exploded_path::feasible_p): Pass a
2486         rejected_constraint ** to model.maybe_update_for_edge and transfer
2487         ownership of any created instance to any feasibility_problem.
2488         (feasibility_problem::dump_to_pp): New.
2489         * exploded-graph.h (feasibility_problem::feasibility_problem):
2490         Drop "model" param; add rejected_constraint * param.
2491         (feasibility_problem::~feasibility_problem): New.
2492         (feasibility_problem::dump_to_pp): New decl.
2493         (feasibility_problem::m_model): Drop field.
2494         (feasibility_problem::m_rc): New field.
2495         * program-point.cc (function_point::get_location): Handle
2496         PK_BEFORE_SUPERNODE and PK_AFTER_SUPERNODE.
2497         * program-state.cc (program_state::on_edge): Pass NULL to new
2498         param of region_model::maybe_update_for_edge.
2499         * region-model.cc (region_model::add_constraint): New overload
2500         adding a rejected_constraint ** param.
2501         (region_model::maybe_update_for_edge): Add rejected_constraint **
2502         param and pass it to the various apply_constraints_for_ calls.
2503         (region_model::apply_constraints_for_gcond): Add
2504         rejected_constraint ** param and pass it to add_constraint calls.
2505         (region_model::apply_constraints_for_gswitch): Likewise.
2506         (region_model::apply_constraints_for_exception): Likewise.
2507         (rejected_constraint::dump_to_pp): New.
2508         * region-model.h (region_model::maybe_update_for_edge):
2509         Add rejected_constraint ** param.
2510         (region_model::add_constraint): New overload adding a
2511         rejected_constraint ** param.
2512         (region_model::apply_constraints_for_gcond): Add
2513         rejected_constraint ** param.
2514         (region_model::apply_constraints_for_gswitch): Likewise.
2515         (region_model::apply_constraints_for_exception): Likewise.
2516         (struct rejected_constraint): New.
2518 2020-09-23  David Malcolm  <dmalcolm@redhat.com>
2520         PR analyzer/97178
2521         * engine.cc (impl_run_checkers): Update for change to ext_state
2522         ctor.
2523         * program-state.cc (selftest::test_sm_state_map): Pass an engine
2524         instance to ext_state ctor.
2525         (selftest::test_program_state_1): Likewise.
2526         (selftest::test_program_state_2): Likewise.
2527         (selftest::test_program_state_merging): Likewise.
2528         (selftest::test_program_state_merging_2): Likewise.
2529         * program-state.h (extrinsic_state::extrinsic_state): Remove NULL
2530         default value for "eng" param.
2532 2020-09-23  Tobias Burnus  <tobias@codesourcery.com>
2534         * analyzer-logging.cc: Guard '#pragma ... ignored "-Wformat-diag"'
2535         by '#if __GNUC__ >= 10'
2536         * analyzer.h: Likewise.
2537         * call-string.cc: Likewise.
2539 2020-09-23  David Malcolm  <dmalcolm@redhat.com>
2541         * engine.cc (exploded_node::on_stmt): Replace sequence of dyn_cast
2542         with switch.
2544 2020-09-22  David Malcolm  <dmalcolm@redhat.com>
2546         * analysis-plan.cc: Include "json.h".
2547         * analyzer.opt (fdump-analyzer-json): New.
2548         * call-string.cc: Include "json.h".
2549         (call_string::to_json): New.
2550         * call-string.h (call_string::to_json): New decl.
2551         * checker-path.cc: Include "json.h".
2552         * constraint-manager.cc: Include "json.h".
2553         (equiv_class::to_json): New.
2554         (constraint::to_json): New.
2555         (constraint_manager::to_json): New.
2556         * constraint-manager.h (equiv_class::to_json): New decl.
2557         (constraint::to_json): New decl.
2558         (constraint_manager::to_json): New decl.
2559         * diagnostic-manager.cc: Include "json.h".
2560         (saved_diagnostic::to_json): New.
2561         (diagnostic_manager::to_json): New.
2562         * diagnostic-manager.h (saved_diagnostic::to_json): New decl.
2563         (diagnostic_manager::to_json): New decl.
2564         * engine.cc: Include "json.h", <zlib.h>.
2565         (exploded_node::status_to_str): New.
2566         (exploded_node::to_json): New.
2567         (exploded_edge::to_json): New.
2568         (exploded_graph::to_json): New.
2569         (dump_analyzer_json): New.
2570         (impl_run_checkers): Call it.
2571         * exploded-graph.h (exploded_node::status_to_str): New decl.
2572         (exploded_node::to_json): New.
2573         (exploded_edge::to_json): New.
2574         (exploded_graph::to_json): New.
2575         * pending-diagnostic.cc: Include "json.h".
2576         * program-point.cc: Include "json.h".
2577         (program_point::to_json): New.
2578         * program-point.h (program_point::to_json): New decl.
2579         * program-state.cc: Include "json.h".
2580         (extrinsic_state::to_json): New.
2581         (sm_state_map::to_json): New.
2582         (program_state::to_json): New.
2583         * program-state.h (extrinsic_state::to_json): New decl.
2584         (sm_state_map::to_json): New decl.
2585         (program_state::to_json): New decl.
2586         * region-model-impl-calls.cc: Include "json.h".
2587         * region-model-manager.cc: Include "json.h".
2588         * region-model-reachability.cc: Include "json.h".
2589         * region-model.cc: Include "json.h".
2590         * region-model.h (svalue::to_json): New decl.
2591         (region::to_json): New decl.
2592         * region.cc: Include "json.h".
2593         (region::to_json: New.
2594         * sm-file.cc: Include "json.h".
2595         * sm-malloc.cc: Include "json.h".
2596         * sm-pattern-test.cc: Include "json.h".
2597         * sm-sensitive.cc: Include "json.h".
2598         * sm-signal.cc: Include "json.h".
2599         (signal_delivery_edge_info_t::to_json): New.
2600         * sm-taint.cc: Include "json.h".
2601         * sm.cc: Include "diagnostic.h", "tree-diagnostic.h", and
2602         "json.h".
2603         (state_machine::state::to_json): New.
2604         (state_machine::to_json): New.
2605         * sm.h (state_machine::state::to_json): New.
2606         (state_machine::to_json): New.
2607         * state-purge.cc: Include "json.h".
2608         * store.cc: Include "json.h".
2609         (binding_key::get_desc): New.
2610         (binding_map::to_json): New.
2611         (binding_cluster::to_json): New.
2612         (store::to_json): New.
2613         * store.h (binding_key::get_desc): New decl.
2614         (binding_map::to_json): New decl.
2615         (binding_cluster::to_json): New decl.
2616         (store::to_json): New decl.
2617         * supergraph.cc: Include "json.h".
2618         (supergraph::to_json): New.
2619         (supernode::to_json): New.
2620         (superedge::to_json): New.
2621         * supergraph.h (supergraph::to_json): New decl.
2622         (supernode::to_json): New decl.
2623         (superedge::to_json): New decl.
2624         * svalue.cc: Include "json.h".
2625         (svalue::to_json): New.
2627 2020-09-21  David Malcolm  <dmalcolm@redhat.com>
2629         PR analyzer/97130
2630         * region-model-impl-calls.cc (call_details::get_arg_type): New.
2631         * region-model.cc (region_model::on_call_pre): Check that the
2632         initial arg is a pointer before calling impl_call_memset and
2633         impl_call_strlen.
2634         * region-model.h (call_details::get_arg_type): New decl.
2636 2020-09-21  David Malcolm  <dmalcolm@redhat.com>
2638         PR analyzer/93355
2639         * sm-malloc.cc (malloc_state_machine::get_default_state): Look at
2640         the base region when considering pointers.  Treat pointers to
2641         decls as being non-heap.
2643 2020-09-18  David Malcolm  <dmalcolm@redhat.com>
2645         * checker-path.cc (warning_event::get_desc): Handle global state
2646         changes.
2648 2020-09-18  David Malcolm  <dmalcolm@redhat.com>
2650         * sm-malloc.cc (malloc_state_machine::on_stmt): Handle strdup and
2651         strndup as being malloc-like allocators.
2653 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2655         * engine.cc (strongly_connected_components::strong_connect): Only
2656         consider intraprocedural edges when creating SCCs.
2657         (worklist::key_t::cmp): Add comment.  Treat call_string
2658         differences as more important than differences of program_point
2659         within a supernode.
2661 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2663         * engine.cc (supernode_cluster::dump_dot): Show the SCC id
2664         in the per-supernode clusters in FILENAME.eg.dot output.
2665         (exploded_graph_annotator::add_node_annotations):
2666         Show the SCC of the supernode in FILENAME.supernode.eg.dot output.
2667         * exploded-graph.h (worklist::scc_id): New.
2668         (exploded_graph::get_scc_id): New.
2670 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2672         * engine.cc (exploded_node::dump_dot): Show STATUS_BULK_MERGED.
2673         (exploded_graph::process_worklist): Call
2674         maybe_process_run_of_before_supernode_enodes.
2675         (exploded_graph::maybe_process_run_of_before_supernode_enodes):
2676         New.
2677         (exploded_graph_annotator::print_enode): Show STATUS_BULK_MERGED.
2678         * exploded-graph.h (enum exploded_node::status): Add
2679         STATUS_BULK_MERGED.
2681 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2683         * engine.cc
2684         (exploded_graph::process_node) <case PK_BEFORE_SUPERNODE>:
2685         Simplify by using program_point::get_next.
2686         * program-point.cc (program_point::get_next): New.
2687         * program-point.h (program_point::get_next): New decl.
2689 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2691         * engine.cc (exploded_graph::get_or_create_node): Show the
2692         program point when issuing -Wanalyzer-too-complex due to hitting
2693         the per-program-point limit.
2695 2020-09-16  David Malcolm  <dmalcolm@redhat.com>
2697         * region-model.cc (region_model::on_call_pre): Treat getchar as
2698         having no side-effects.
2700 2020-09-15  David Malcolm  <dmalcolm@redhat.com>
2702         PR analyzer/96650
2703         * constraint-manager.cc (merger_fact_visitor::on_fact): Replace
2704         assertion that add_constraint succeeded with an assertion that
2705         if it fails, -fanalyzer-transitivity is off.
2707 2020-09-14  David Malcolm  <dmalcolm@redhat.com>
2709         * analyzer.opt (-param=analyzer-max-constraints=): New param.
2710         * constraint-manager.cc
2711         (constraint_manager::add_constraint_internal): Silently reject
2712         attempts to add constraints when the above limit is reached.
2714 2020-09-14  David Malcolm  <dmalcolm@redhat.com>
2716         PR analyzer/96653
2717         * constraint-manager.cc
2718         (constraint_manager::get_or_add_equiv_class): Don't accumulate
2719         transitive closure of all constraints on constants.
2721 2020-09-14  David Malcolm  <dmalcolm@redhat.com>
2723         PR analyzer/97029
2724         * analyzer.cc (is_setjmp_call_p): Require the initial arg to be a
2725         pointer.
2726         * region-model.cc (region_model::deref_rvalue): Assert that the
2727         svalue is of pointer type.
2729 2020-09-11  David Malcolm  <dmalcolm@redhat.com>
2731         PR analyzer/96798
2732         * region-model-impl-calls.cc (region_model::impl_call_memcpy):
2733         New.
2734         (region_model::impl_call_strcpy): New.
2735         * region-model.cc (region_model::on_call_pre): Flag unhandled
2736         builtins that are non-pure as having unknown side-effects.
2737         Implement BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_STRCPY,
2738         BUILT_IN_STRCPY_CHK, BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED,
2739         BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_FPUTC,
2740         BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED,
2741         BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF,
2742         BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTCHAR,
2743         BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED,
2744         BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF.
2745         * region-model.h (region_model::impl_call_memcpy): New decl.
2746         (region_model::impl_call_strcpy): New decl.
2748 2020-09-09  David Malcolm  <dmalcolm@redhat.com>
2750         PR analyzer/94355
2751         * analyzer.opt (Wanalyzer-mismatching-deallocation): New warning.
2752         * region-model-impl-calls.cc
2753         (region_model::impl_call_operator_new): New.
2754         (region_model::impl_call_operator_delete): New.
2755         * region-model.cc (region_model::on_call_pre): Detect operator new
2756         and operator delete.
2757         (region_model::on_call_post): Likewise.
2758         (region_model::maybe_update_for_edge): Detect EH edges and call...
2759         (region_model::apply_constraints_for_exception): New function.
2760         * region-model.h (region_model::impl_call_operator_new): New decl.
2761         (region_model::impl_call_operator_delete): New decl.
2762         (region_model::apply_constraints_for_exception): New decl.
2763         * sm-malloc.cc (enum resource_state): New.
2764         (struct allocation_state): New state subclass.
2765         (enum wording): New.
2766         (struct api): New.
2767         (malloc_state_machine::custom_data_t): New typedef.
2768         (malloc_state_machine::add_state): New decl.
2769         (malloc_state_machine::m_unchecked)
2770         (malloc_state_machine::m_nonnull)
2771         (malloc_state_machine::m_freed): Delete these states in favor
2772         of...
2773         (malloc_state_machine::m_malloc)
2774         (malloc_state_machine::m_scalar_new)
2775         (malloc_state_machine::m_vector_new): ...this new api instances,
2776         which own their own versions of these states.
2777         (malloc_state_machine::on_allocator_call): New decl.
2778         (malloc_state_machine::on_deallocator_call): New decl.
2779         (api::api): New ctor.
2780         (dyn_cast_allocation_state): New.
2781         (as_a_allocation_state): New.
2782         (get_rs): New.
2783         (unchecked_p): New.
2784         (nonnull_p): New.
2785         (freed_p): New.
2786         (malloc_diagnostic::describe_state_change): Use unchecked_p and
2787         nonnull_p.
2788         (class mismatching_deallocation): New.
2789         (double_free::double_free): Add funcname param for initializing
2790         m_funcname.
2791         (double_free::emit): Use m_funcname in warning message rather
2792         than hardcoding "free".
2793         (double_free::describe_state_change): Likewise.  Use freed_p.
2794         (double_free::describe_call_with_state): Use freed_p.
2795         (double_free::describe_final_event): Use m_funcname in message
2796         rather than hardcoding "free".
2797         (double_free::m_funcname): New field.
2798         (possible_null::describe_state_change): Use unchecked_p.
2799         (possible_null::describe_return_of_state): Likewise.
2800         (use_after_free::use_after_free): Add param for initializing m_api.
2801         (use_after_free::emit): Use m_api->m_dealloc_funcname in message
2802         rather than hardcoding "free".
2803         (use_after_free::describe_state_change): Use freed_p.  Change the
2804         wording of the message based on the API.
2805         (use_after_free::describe_final_event): Use
2806         m_api->m_dealloc_funcname in message rather than hardcoding
2807         "free".  Change the wording of the message based on the API.
2808         (use_after_free::m_api): New field.
2809         (malloc_leak::describe_state_change): Use unchecked_p.  Update
2810         for renaming of m_malloc_event to m_alloc_event.
2811         (malloc_leak::describe_final_event): Update for renaming of
2812         m_malloc_event to m_alloc_event.
2813         (malloc_leak::m_malloc_event): Rename...
2814         (malloc_leak::m_alloc_event): ...to this.
2815         (free_of_non_heap::free_of_non_heap): Add param for initializing
2816         m_funcname.
2817         (free_of_non_heap::emit): Use m_funcname in message rather than
2818         hardcoding "free".
2819         (free_of_non_heap::describe_final_event): Likewise.
2820         (free_of_non_heap::m_funcname): New field.
2821         (allocation_state::dump_to_pp): New.
2822         (allocation_state::get_nonnull): New.
2823         (malloc_state_machine::malloc_state_machine): Update for changes
2824         to state fields and new api fields.
2825         (malloc_state_machine::add_state): New.
2826         (malloc_state_machine::on_stmt): Move malloc/calloc handling to
2827         on_allocator_call and call it, passing in the API pointer.
2828         Likewise for free, moving it to on_deallocator_call.  Handle calls
2829         to operator new and delete in an analogous way.  Use unchecked_p
2830         when testing for possibly-null-arg and possibly-null-deref, and
2831         transition to the non-null for the correct API.  Remove redundant
2832         node param from call to on_zero_assignment.  Use freed_p for
2833         use-after-free check, and pass in API.
2834         (malloc_state_machine::on_allocator_call): New, based on code in
2835         on_stmt.
2836         (malloc_state_machine::on_deallocator_call): Likewise.
2837         (malloc_state_machine::on_phi): Mark node param with
2838         ATTRIBUTE_UNUSED; don't pass it to on_zero_assignment.
2839         (malloc_state_machine::on_condition): Mark node param with
2840         ATTRIBUTE_UNUSED.  Replace on_transition calls with get_state and
2841         set_next_state pairs, transitioning to the non-null state for the
2842         appropriate API.
2843         (malloc_state_machine::can_purge_p): Port to new state approach.
2844         (malloc_state_machine::on_zero_assignment): Replace on_transition
2845         calls with get_state and set_next_state pairs.  Drop redundant
2846         node param.
2847         * sm.h (state_machine::add_custom_state): New.
2849 2020-09-09  David Malcolm  <dmalcolm@redhat.com>
2851         * diagnostic-manager.cc
2852         (null_assignment_sm_context::warn_for_state): Replace with...
2853         (null_assignment_sm_context::warn): ...this.
2854         * engine.cc (impl_sm_context::warn_for_state): Replace with...
2855         (impl_sm_context::warn): ...this.
2856         * sm-file.cc (fileptr_state_machine::on_stmt): Replace
2857         warn_for_state and on_transition calls with a get_state
2858         test guarding warn and set_next_state calls.
2859         * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise.
2860         * sm-pattern-test.cc (pattern_test_state_machine::on_condition):
2861         Replace warn_for_state call with warn call.
2862         * sm-sensitive.cc
2863         (sensitive_state_machine::warn_for_any_exposure): Replace
2864         warn_for_state call with a get_state test guarding a warn call.
2865         * sm-signal.cc (signal_state_machine::on_stmt): Likewise.
2866         * sm-taint.cc (taint_state_machine::on_stmt):  Replace
2867         warn_for_state and on_transition calls with a get_state
2868         test guarding warn and set_next_state calls.
2869         * sm.h (sm_context::warn_for_state): Replace with...
2870         (sm_context::warn): ...this.
2872 2020-09-09  David Malcolm  <dmalcolm@redhat.com>
2874         * diagnostic-manager.cc
2875         (null_assignment_sm_context::null_assignment_sm_context): Add old_state
2876         and ext_state params, initializing m_old_state and m_ext_state.
2877         (null_assignment_sm_context::on_transition): Split into...
2878         (null_assignment_sm_context::get_state): ...this new vfunc
2879         implementation and...
2880         (null_assignment_sm_context::set_next_state): ...this new vfunc
2881         implementation.
2882         (null_assignment_sm_context::m_old_state): New field.
2883         (null_assignment_sm_context::m_ext_state): New field.
2884         (diagnostic_manager::add_events_for_eedge): Pass in old state and
2885         ext_state when creating sm_ctxt.
2886         * engine.cc (impl_sm_context::on_transition): Split into...
2887         (impl_sm_context::get_state): ...this new vfunc
2888         implementation and...
2889         (impl_sm_context::set_next_state): ...this new vfunc
2890         implementation.
2891         * sm.h (sm_context::get_state): New pure virtual function.
2892         (sm_context::set_next_state): Likewise.
2893         (sm_context::on_transition): Convert from a pure virtual function
2894         to a regular function implemented in terms of get_state and
2895         set_next_state.
2897 2020-09-09  David Malcolm  <dmalcolm@redhat.com>
2899         * checker-path.cc (state_change_event::get_desc): Update
2900         state_machine::get_state_name calls to state::get_name.
2901         (warning_event::get_desc): Likewise.
2902         * diagnostic-manager.cc
2903         (null_assignment_sm_context::on_transition): Update comparison
2904         against 0 with comparison with m_sm.get_start_state.
2905         (diagnostic_manager::prune_for_sm_diagnostic): Update
2906         state_machine::get_state_name calls to state::get_name.
2907         * engine.cc (impl_sm_context::on_transition): Likewise.
2908         (exploded_node::get_dot_fillcolor): Use get_id when summing
2909         the sm states.
2910         * program-state.cc (sm_state_map::sm_state_map): Don't hardcode
2911         0 as the start state when initializing m_global_state.
2912         (sm_state_map::print): Use dump_to_pp rather than get_state_name
2913         when dumping states.
2914         (sm_state_map::is_empty_p): Don't hardcode 0 as the start state
2915         when examining m_global_state.
2916         (sm_state_map::hash): Use get_id when hashing states.
2917         (selftest::test_sm_state_map): Use state objects rather than
2918         arbitrary hardcoded integers.
2919         (selftest::test_program_state_merging): Likewise.
2920         (selftest::test_program_state_merging_2): Likewise.
2921         * sm-file.cc (fileptr_state_machine::m_start): Move to base class.
2922         (file_diagnostic::describe_state_change): Use get_start_state.
2923         (fileptr_state_machine::fileptr_state_machine): Drop m_start
2924         initialization.
2925         * sm-malloc.cc (malloc_state_machine::m_start): Move to base
2926         class.
2927         (malloc_diagnostic::describe_state_change): Use get_start_state.
2928         (possible_null::describe_state_change): Likewise.
2929         (malloc_state_machine::malloc_state_machine): Drop m_start
2930         initialization.
2931         * sm-pattern-test.cc (pattern_test_state_machine::m_start): Move
2932         to base class.
2933         (pattern_test_state_machine::pattern_test_state_machine): Drop
2934         m_start initialization.
2935         * sm-sensitive.cc (sensitive_state_machine::m_start): Move to base
2936         class.
2937         (sensitive_state_machine::sensitive_state_machine): Drop m_start
2938         initialization.
2939         * sm-signal.cc (signal_state_machine::m_start): Move to base
2940         class.
2941         (signal_state_machine::signal_state_machine): Drop m_start
2942         initialization.
2943         * sm-taint.cc (taint_state_machine::m_start): Move to base class.
2944         (taint_state_machine::taint_state_machine): Drop m_start
2945         initialization.
2946         * sm.cc (state_machine::state::dump_to_pp): New.
2947         (state_machine::state_machine): Move here from sm.h.  Initialize
2948         m_next_state_id and m_start.
2949         (state_machine::add_state): Reimplement in terms of state objects.
2950         (state_machine::get_state_name): Delete.
2951         (state_machine::get_state_by_name): Reimplement in terms of state
2952         objects.  Make const.
2953         (state_machine::validate): Delete.
2954         (state_machine::dump_to_pp): Reimplement in terms of state
2955         objects.
2956         * sm.h (state_machine::state): New class.
2957         (state_machine::state_t): Convert typedef from "unsigned" to
2958         "const state_machine::state *".
2959         (state_machine::state_machine): Move to sm.cc.
2960         (state_machine::get_default_state): Use m_start rather than
2961         hardcoding 0.
2962         (state_machine::get_state_name): Delete.
2963         (state_machine::get_state_by_name): Make const.
2964         (state_machine::get_start_state): New accessor.
2965         (state_machine::alloc_state_id): New.
2966         (state_machine::m_state_names): Drop in favor of...
2967         (state_machine::m_states): New field
2968         (state_machine::m_start): New field
2969         (start_start_p): Delete.
2971 2020-09-08  David Malcolm  <dmalcolm@redhat.com>
2973         PR analyzer/96949
2974         * store.cc (binding_map::apply_ctor_val_to_range): Add
2975         error-handling for the cases where we have symbolic offsets.
2977 2020-09-08  David Malcolm  <dmalcolm@redhat.com>
2979         PR analyzer/96950
2980         * store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
2981         where min_index == max_index.
2982         (binding_map::apply_ctor_val_to_range): Replace assertion that we
2983         don't have a CONSTRUCTOR value with error-handling.
2985 2020-09-08  David Malcolm  <dmalcolm@redhat.com>
2987         PR analyzer/96962
2988         * region-model.cc (region_model::on_call_pre): Fix guard on switch
2989         on built-ins to only consider BUILT_IN_NORMAL, rather than other
2990         kinds of build-ins.
2992 2020-09-01  David Malcolm  <dmalcolm@redhat.com>
2994         PR analyzer/96792
2995         * region-model.cc (region_model::deref_rvalue): Add the constraint
2996         that PTR_SVAL is non-NULL.
2998 2020-08-31  David Malcolm  <dmalcolm@redhat.com>
3000         PR analyzer/96798
3001         * region-model.cc (region_model::on_call_pre): Handle
3002         BUILT_IN_MEMSET_CHK.
3004 2020-08-31  David Malcolm  <dmalcolm@redhat.com>
3006         * region-model.cc (region_model::on_call_pre): Gather handling of
3007         builtins and of internal fns into switch statements.  Handle
3008         "alloca" and BUILT_IN_ALLOCA_WITH_ALIGN.
3010 2020-08-31  David Malcolm  <dmalcolm@redhat.com>
3012         PR analyzer/96860
3013         * region.cc (decl_region::get_svalue_for_constructor): Support
3014         apply_ctor_to_region failing.
3015         * store.cc (binding_map::apply_ctor_to_region): Add failure
3016         handling.
3017         (binding_map::apply_ctor_val_to_range): Likewise.
3018         (binding_map::apply_ctor_pair_to_child_region): Likewise.  Replace
3019         assertion that child_base_offset is not symbolic with error
3020         handling.
3021         * store.h (binding_map::apply_ctor_to_region): Convert return type
3022         from void to bool.
3023         (binding_map::apply_ctor_val_to_range): Likewise.
3024         (binding_map::apply_ctor_pair_to_child_region): Likewise.
3026 2020-08-31  David Malcolm  <dmalcolm@redhat.com>
3028         PR analyzer/96763
3029         * store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
3030         by calling a new binding_map::apply_ctor_val_to_range subroutine.
3031         Split out the existing non-CONSTRUCTOR-handling code to a new
3032         apply_ctor_pair_to_child_region subroutine.
3033         (binding_map::apply_ctor_val_to_range): New.
3034         (binding_map::apply_ctor_pair_to_child_region): New, split out
3035         from binding_map::apply_ctor_to_region as noted above.
3036         * store.h (binding_map::apply_ctor_val_to_range): New decl.
3037         (binding_map::apply_ctor_pair_to_child_region): New decl.
3039 2020-08-31  David Malcolm  <dmalcolm@redhat.com>
3041         PR analyzer/96764
3042         * region-model-manager.cc
3043         (region_model_manager::maybe_fold_unaryop): Handle VIEW_CONVERT_EXPR.
3044         (region_model_manager::get_or_create_cast): Move logic for
3045         real->integer casting to...
3046         (get_code_for_cast): ...this new function, and add logic for
3047         real->non-integer casts.
3048         (region_model_manager::maybe_fold_sub_svalue): Handle
3049         VIEW_CONVERT_EXPR.
3050         * region-model.cc
3051         (region_model::add_any_constraints_from_gassign): Likewise.
3052         * svalue.cc (svalue::maybe_undo_cast): Likewise.
3053         (unaryop_svalue::dump_to_pp): Likewise.
3055 2020-08-26  David Malcolm  <dmalcolm@redhat.com>
3057         PR analyzer/94858
3058         * region-model-manager.cc
3059         (region_model_manager::get_or_create_widening_svalue): Assert that
3060         neither of the inputs are themselves widenings.
3061         * store.cc (store::eval_alias_1): The initial value of a pointer
3062         can't point to a region that was allocated on the heap after the
3063         beginning of the path.  A widened pointer value can't alias anything
3064         that the initial pointer value can't alias.
3065         * svalue.cc (svalue::can_merge_p): Merge BINOP (X, OP, CST) with X
3066         to a widening svalue.  Merge
3067         BINOP(WIDENING(BASE, BINOP(BASE, X)), X) and BINOP(BASE, X) to
3068         to the LHS of the first BINOP.
3070 2020-08-26  David Malcolm  <dmalcolm@redhat.com>
3072         PR analyzer/96777
3073         * region-model.h (class compound_svalue): Document that all keys
3074         must be concrete.
3075         (compound_svalue::compound_svalue): Move definition to svalue.cc.
3076         * store.cc (binding_map::apply_ctor_to_region): Handle
3077         initializers for trailing arrays with incomplete size.
3078         * svalue.cc (compound_svalue::compound_svalue): Move definition
3079         here from region-model.h.  Add assertion that all keys are
3080         concrete.
3082 2020-08-22  David Malcolm  <dmalcolm@redhat.com>
3084         PR analyzer/94851
3085         * region-model-manager.cc
3086         (region_model_manager::maybe_fold_binop): Fold bitwise "& 0" to 0.
3088 2020-08-22  David Malcolm  <dmalcolm@redhat.com>
3090         * store.cc (store::eval_alias): Make const.  Split out 2nd half
3091         into store::eval_alias_1 and call it twice for symmetry, avoiding
3092         test duplication.
3093         (store::eval_alias_1): New function, split out from the above.
3094         * store.h (store::eval_alias): Make const.
3095         (store::eval_alias_1): New decl.
3097 2020-08-22  David Malcolm  <dmalcolm@redhat.com>
3099         * region-model.cc (region_model::push_frame): Bind the default
3100         SSA name for each parm if it exists, falling back to the parm
3101         itself otherwise, rather than doing both.
3103 2020-08-20  David Malcolm  <dmalcolm@redhat.com>
3105         PR analyzer/96723
3106         * region-model-manager.cc
3107         (region_model_manager::get_field_region): Assert that field is a
3108         FIELD_DECL.
3109         * region.cc (region::get_subregions_for_binding): In
3110         union-handling, filter the TYPE_FIELDS traversal to just FIELD_DECLs.
3112 2020-08-20  David Malcolm  <dmalcolm@redhat.com>
3114         PR analyzer/96713
3115         * region-model.cc (region_model::get_gassign_result): For
3116         comparisons, only use eval_condition when the lhs has boolean
3117         type, and use get_or_create_constant_svalue on the boolean
3118         constants directly rather than via get_rvalue.
3120 2020-08-19  David Malcolm  <dmalcolm@redhat.com>
3122         PR analyzer/96643
3123         * region-model.cc (region_model::deref_rvalue): Rather than
3124         attempting to handle all svalue kinds in the switch, only cover
3125         the special cases, and move symbolic-region handling to after
3126         the switch, thus implicitly handling the missing case SK_COMPOUND.
3128 2020-08-19  David Malcolm  <dmalcolm@redhat.com>
3130         PR analyzer/96705
3131         * region-model-manager.cc
3132         (region_model_manager::maybe_fold_binop): Check that we have an
3133         integral type before calling build_int_cst.
3135 2020-08-19  David Malcolm  <dmalcolm@redhat.com>
3137         PR analyzer/96699
3138         * region-model-manager.cc
3139         (region_model_manager::get_or_create_cast): Use FIX_TRUNC_EXPR for
3140         casting from REAL_TYPE to INTEGER_TYPE.
3142 2020-08-19  David Malcolm  <dmalcolm@redhat.com>
3144         PR analyzer/96651
3145         * region-model.cc (region_model::called_from_main_p): New.
3146         (region_model::get_store_value): Move handling for globals into...
3147         (region_model::get_initial_value_for_global): ...this new
3148         function, and add logic for extracting values from decl
3149         initializers.
3150         * region-model.h (decl_region::get_svalue_for_constructor): New
3151         decl.
3152         (decl_region::get_svalue_for_initializer): New decl.
3153         (region_model::called_from_main_p): New decl.
3154         (region_model::get_initial_value_for_global): New.
3155         * region.cc (decl_region::maybe_get_constant_value): Move logic
3156         for getting an svalue from a CONSTRUCTOR node to...
3157         (decl_region::get_svalue_for_constructor): ...this new function.
3158         (decl_region::get_svalue_for_initializer): New.
3159         * store.cc (get_svalue_for_ctor_val): Rewrite in terms of
3160         region_model::get_rvalue.
3161         * store.h (binding_cluster::get_map): New accessor.
3163 2020-08-19  David Malcolm  <dmalcolm@redhat.com>
3165         PR analyzer/96648
3166         * region.cc (get_field_at_bit_offset): Gracefully handle negative
3167         values for bit_offset.
3169 2020-08-18  David Malcolm  <dmalcolm@redhat.com>
3171         * region-model.cc (region_model::get_rvalue_1): Fix name of local.
3173 2020-08-18  David Malcolm  <dmalcolm@redhat.com>
3175         PR analyzer/96641
3176         * region-model.cc (region_model::get_rvalue_1): Handle
3177         unrecognized tree codes by returning "UNKNOWN.
3179 2020-08-18  David Malcolm  <dmalcolm@redhat.com>
3181         PR analyzer/96640
3182         * region-model.cc (region_model::get_gassign_result): Handle various
3183         VEC_* tree codes by returning UNKNOWN.
3184         (region_model::on_assignment): Handle unrecognized tree codes by
3185         setting lhs to an unknown value, rather than issuing a "sorry" and
3186         asserting.
3188 2020-08-17  David Malcolm  <dmalcolm@redhat.com>
3190         PR analyzer/96644
3191         * region-model-manager.cc (get_region_for_unexpected_tree_code):
3192         Handle ctxt being NULL.
3194 2020-08-17  David Malcolm  <dmalcolm@redhat.com>
3196         PR analyzer/96639
3197         * region.cc (region::get_subregions_for_binding): Check for "type"
3198         being NULL.
3200 2020-08-17  David Malcolm  <dmalcolm@redhat.com>
3202         PR analyzer/96642
3203         * store.cc (get_svalue_for_ctor_val): New.
3204         (binding_map::apply_ctor_to_region): Call it.
3206 2020-08-14  David Malcolm  <dmalcolm@redhat.com>
3208         PR testsuite/96609
3209         PR analyzer/96616
3210         * region-model.cc (region_model::get_store_value): Call
3211         maybe_get_constant_value on decl_regions first.
3212         * region-model.h (decl_region::maybe_get_constant_value): New decl.
3213         * region.cc (decl_region::get_stack_depth): Likewise.
3214         (decl_region::maybe_get_constant_value): New.
3215         * store.cc (get_subregion_within_ctor): New.
3216         (binding_map::apply_ctor_to_region): New.
3217         * store.h (binding_map::apply_ctor_to_region): New decl.
3219 2020-08-14  David Malcolm  <dmalcolm@redhat.com>
3221         PR analyzer/96611
3222         * store.cc (store::mark_as_escaped): Reject attempts to
3223         get a cluster for an unknown pointer.
3225 2020-08-13  David Malcolm  <dmalcolm@redhat.com>
3227         PR analyzer/93032
3228         PR analyzer/93938
3229         PR analyzer/94011
3230         PR analyzer/94099
3231         PR analyzer/94399
3232         PR analyzer/94458
3233         PR analyzer/94503
3234         PR analyzer/94640
3235         PR analyzer/94688
3236         PR analyzer/94689
3237         PR analyzer/94839
3238         PR analyzer/95026
3239         PR analyzer/95042
3240         PR analyzer/95240
3241         * analyzer-logging.cc: Ignore "-Wformat-diag".
3242         (logger::enter_scope): Use inc_indent in both overloads.
3243         (logger::exit_scope): Use dec_indent.
3244         * analyzer-logging.h (logger::inc_indent): New.
3245         (logger::dec_indent): New.
3246         * analyzer-selftests.cc (run_analyzer_selftests): Call
3247         analyzer_store_cc_tests.
3248         * analyzer-selftests.h (analyzer_store_cc_tests): New decl.
3249         * analyzer.cc (get_stmt_location): New function.
3250         * analyzer.h (class initial_svalue): New forward decl.
3251         (class unaryop_svalue): New forward decl.
3252         (class binop_svalue): New forward decl.
3253         (class sub_svalue): New forward decl.
3254         (class unmergeable_svalue): New forward decl.
3255         (class placeholder_svalue): New forward decl.
3256         (class widening_svalue): New forward decl.
3257         (class compound_svalue): New forward decl.
3258         (class conjured_svalue): New forward decl.
3259         (svalue_set): New typedef.
3260         (class map_region): Delete.
3261         (class array_region): Delete.
3262         (class frame_region): New forward decl.
3263         (class function_region): New forward decl.
3264         (class label_region): New forward decl.
3265         (class decl_region): New forward decl.
3266         (class element_region): New forward decl.
3267         (class offset_region): New forward decl.
3268         (class cast_region): New forward decl.
3269         (class field_region): New forward decl.
3270         (class string_region): New forward decl.
3271         (class region_model_manager): New forward decl.
3272         (class store_manager): New forward decl.
3273         (class store): New forward decl.
3274         (class call_details): New forward decl.
3275         (struct svalue_id_merger_mapping): Delete.
3276         (struct canonicalization): Delete.
3277         (class function_point): New forward decl.
3278         (class engine): New forward decl.
3279         (dump_tree): New function decl.
3280         (print_quoted_type): New function decl.
3281         (readability_comparator): New function decl.
3282         (tree_cmp): New function decl.
3283         (class path_var): Move here from region-model.h
3284         (bit_offset_t, bit_size_t, byte_size_t): New typedefs.
3285         (class region_offset): New class.
3286         (get_stmt_location): New decl.
3287         (struct member_function_hash_traits): New struct.
3288         (class consolidation_map): New class.
3289         Ignore "-Wformat-diag".
3290         * analyzer.opt (-param=analyzer-max-svalue-depth=): New param.
3291         (-param=analyzer-max-enodes-for-full-dump=): New param.
3292         * call-string.cc: Ignore -Wformat-diag.
3293         * checker-path.cc: Move includes of "analyzer/call-string.h" and
3294         "analyzer/program-point.h" to before "analyzer/region-model.h",
3295         and also include "analyzer/store.h" before it.
3296         (state_change_event::state_change_event): Replace "tree var" param
3297         with "const svalue *sval".  Convert "origin" param from tree to
3298         "const svalue *".
3299         (state_change_event::get_desc): Call get_representative_tree to
3300         convert the var and origin from const svalue * to tree.  Use
3301         svalue::get_desc rather than %qE when describing state changes.
3302         (checker_path::add_final_event): Use get_stmt_location.
3303         * checker-path.h (state_change_event::state_change_event): Port
3304         from tree to const svalue *.
3305         (state_change_event::get_lvalue): Delete.
3306         (state_change_event::get_dest_function): New.
3307         (state_change_event::m_var): Replace with...
3308         (state_change_event::m_sval): ...this.
3309         (state_change_event::m_origin): Convert from tree to
3310         const svalue *.
3311         * constraint-manager.cc: Include "analyzer/call-string.h",
3312         "analyzer/program-point.h", and "analyzer/store.h" before
3313         "analyzer/region-model.h".
3314         (struct bound, struct range): Move to constraint-manager.h.
3315         (compare_constants): New function.
3316         (range::dump): Rename to...
3317         (range::dump_to_pp): ...this.  Support NULL constants.
3318         (range::dump): Reintroduce for dumping to stderr.
3319         (range::constrained_to_single_element): Return result, rather than
3320         writing to *OUT.
3321         (range::eval_condition): New.
3322         (range::below_lower_bound): New.
3323         (range::above_upper_bound): New.
3324         (equiv_class::equiv_class): Port from svalue_id to const svalue *.
3325         (equiv_class::print): Likewise.
3326         (equiv_class::hash): Likewise.
3327         (equiv_class::operator==): Port from svalue_id to const svalue *.
3328         (equiv_class::add): Port from svalue_id to const svalue *. Drop
3329         "cm" param.
3330         (equiv_class::del): Port from svalue_id to const svalue *.
3331         (equiv_class::get_representative): Likewise.
3332         (equiv_class::remap_svalue_ids): Delete.
3333         (svalue_id_cmp_by_id): Rename to...
3334         (svalue_cmp_by_ptr): ...this, porting from svalue_id to
3335         const svalue *.
3336         (equiv_class::canonicalize): Update qsort comparator.
3337         (constraint::implied_by): New.
3338         (constraint_manager::constraint_manager): Copy m_mgr in copy ctor.
3339         (constraint_manager::dump_to_pp): Add "multiline" param
3340         (constraint_manager::dump): Pass "true" for "multiline".
3341         (constraint_manager::add_constraint): Port from svalue_id to
3342         const svalue *.  Split out second part into...
3343         (constraint_manager::add_unknown_constraint): ...this new
3344         function.  Remove self-constraints when merging equivalence
3345         classes.
3346         (constraint_manager::add_constraint_internal): Remove constraints
3347         that would be implied by the new constraint.  Port from svalue_id
3348         to const svalue *.
3349         (constraint_manager::get_equiv_class_by_sid): Rename to...
3350         (constraint_manager::get_equiv_class_by_svalue): ...this, porting
3351         from svalue_id to const svalue *.
3352         (constraint_manager::get_or_add_equiv_class): Port from svalue_id
3353         to const svalue *.
3354         (constraint_manager::eval_condition): Make const.  Call
3355         compare_constants and return early if it provides a known result.
3356         (constraint_manager::get_ec_bounds): New.
3357         (constraint_manager::eval_condition): New overloads.  Make
3358         existing one const, and use compare_constants.
3359         (constraint_manager::purge): Convert "p" param to a template
3360         rather that an abstract base class.  Port from svalue_id to
3361         const svalue *.
3362         (class dead_svalue_purger): New class.
3363         (constraint_manager::remap_svalue_ids): Delete.
3364         (constraint_manager::on_liveness_change): New.
3365         (equiv_class_cmp): Port from svalue_id to const svalue *.
3366         (constraint_manager::canonicalize): Likewise.  Combine with
3367         purging of redundant equivalence classes and constraints.
3368         (class cleaned_constraint_manager): Delete.
3369         (class merger_fact_visitor): Make "m_cm_b" const.  Add "m_merger"
3370         field.
3371         (merger_fact_visitor::fact): Port from svalue_id to const svalue *.
3372         Add special case for widening.
3373         (constraint_manager::merge): Port from svalue_id to const svalue *.
3374         (constraint_manager::clean_merger_input): Delete.
3375         (constraint_manager::for_each_fact): Port from svalue_id to
3376         const svalue *.
3377         (constraint_manager::validate): Likewise.
3378         (selftest::test_constraint_conditions): Provide a
3379         region_model_manager when creating region_model instances.
3380         Add test for self-equality not creating equivalence classes.
3381         (selftest::test_transitivity): Provide a region_model_manager when
3382         creating region_model instances.  Verify that EC-merging happens
3383         when constraints are implied.
3384         (selftest::test_constant_comparisons):  Provide a
3385         region_model_manager when creating region_model instances.
3386         (selftest::test_constraint_impl): Likewise.  Remove over-specified
3387         assertions.
3388         (selftest::test_equality): Provide a region_model_manager when
3389         creating region_model instances.
3390         (selftest::test_many_constants): Likewise.  Provide a
3391         program_point when testing merging.
3392         (selftest::run_constraint_manager_tests): Move call to
3393         test_constant_comparisons to outside the transitivity guard.
3394         * constraint-manager.h (struct bound): Move here from
3395         constraint-manager.cc.
3396         (struct range): Likewise.
3397         (struct::eval_condition): New decl.
3398         (struct::below_lower_bound): New decl.
3399         (struct::above_upper_bound): New decl.
3400         (equiv_class::add): Port from svalue_id to const svalue *.
3401         (equiv_class::del): Likewise.
3402         (equiv_class::get_representative): Likewise.
3403         (equiv_class::remap_svalue_ids): Drop.
3404         (equiv_class::m_cst_sid): Convert to..
3405         (equiv_class::m_cst_sval): ...this.
3406         (equiv_class::m_vars): Port from svalue_id to const svalue *.
3407         (constraint::bool implied_by): New decl.
3408         (fact_visitor::on_fact): Port from svalue_id to const svalue *.
3409         (constraint_manager::constraint_manager): Add mgr param.
3410         (constraint_manager::clone): Delete.
3411         (constraint_manager::maybe_get_constant): Delete.
3412         (constraint_manager::get_sid_for_constant): Delete.
3413         (constraint_manager::get_num_svalues): Delete.
3414         (constraint_manager::dump_to_pp): Add "multiline" param.
3415         (constraint_manager::get_equiv_class): Port from svalue_id to
3416         const svalue *.
3417         (constraint_manager::add_constraint):  Likewise.
3418         (constraint_manager::get_equiv_class_by_sid): Rename to...
3419         (constraint_manager::get_equiv_class_by_svalue): ...this, porting
3420         from svalue_id to const svalue *.
3421         (constraint_manager::add_unknown_constraint): New decl.
3422         (constraint_manager::get_or_add_equiv_class): Port from svalue_id
3423         to const svalue *.
3424         (constraint_manager::eval_condition): Likewise.  Add overloads.
3425         (constraint_manager::get_ec_bounds): New decl.
3426         (constraint_manager::purge): Convert to template.
3427         (constraint_manager::remap_svalue_ids): Delete.
3428         (constraint_manager::on_liveness_change): New decl.
3429         (constraint_manager::canonicalize): Drop param.
3430         (constraint_manager::clean_merger_input): Delete.
3431         (constraint_manager::m_mgr): New field.
3432         * diagnostic-manager.cc: Move includes of
3433         "analyzer/call-string.h" and "analyzer/program-point.h" to before
3434         "analyzer/region-model.h", and also include "analyzer/store.h"
3435         before it.
3436         (saved_diagnostic::saved_diagnostic): Add "sval" param.
3437         (diagnostic_manager::diagnostic_manager): Add engine param.
3438         (diagnostic_manager::add_diagnostic): Add "sval" param, passing it
3439         to saved_diagnostic ctor.  Update overload to pass NULL for it.
3440         (dedupe_winners::dedupe_winners): Add engine param.
3441         (dedupe_winners::add): Add "eg" param.  Pass m_engine to
3442         feasible_p.
3443         (dedupe_winner::m_engine): New field.
3444         (diagnostic_manager::emit_saved_diagnostics): Pass engine to
3445         dedupe_winners.  Pass &eg when adding candidates.  Pass svalue
3446         rather than tree to prune_path.  Use get_stmt_location to get
3447         primary location of diagnostic.
3448         (diagnostic_manager::emit_saved_diagnostic): Likewise.
3449         (get_any_origin): Drop.
3450         (state_change_event_creator::on_global_state_change): Pass NULL
3451         const svalue * rather than NULL_TREE trees to state_change_event
3452         ctor.
3453         (state_change_event_creator::on_state_change): Port from tree and
3454         svalue_id to const svalue *.
3455         (for_each_state_change): Port from svalue_id to const svalue *.
3456         (struct null_assignment_sm_context): New.
3457         (diagnostic_manager::add_events_for_eedge):  Add state change
3458         events for assignment to NULL.
3459         (diagnostic_manager::prune_path): Update param from tree to
3460         const svalue *.
3461         (diagnostic_manager::prune_for_sm_diagnostic): Port from tracking
3462         by tree to by const svalue *.
3463         * diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Add sval
3464         param.
3465         (saved_diagnostic::m_sval): New field.
3466         (diagnostic_manager::diagnostic_manager): Add engine param.
3467         (diagnostic_manager::get_engine): New.
3468         (diagnostic_manager::add_diagnostic): Add "sval" param.
3469         (diagnostic_manager::prune_path): Likewise.
3470         (diagnostic_manager::prune_for_sm_diagnostic): New overload.
3471         (diagnostic_manager::m_eng): New field.
3472         * engine.cc: Move includes of "analyzer/call-string.h" and
3473         "analyzer/program-point.h" to before "analyzer/region-model.h",
3474         and also include "analyzer/store.h" before it.
3475         (impl_region_model_context::impl_region_model_context): Update for
3476         removal of m_change field.
3477         (impl_region_model_context::remap_svalue_ids): Delete.
3478         (impl_region_model_context::on_svalue_leak): New.
3479         (impl_region_model_context::on_svalue_purge): Delete.
3480         (impl_region_model_context::on_liveness_change): New.
3481         (impl_region_model_context::on_unknown_change): Update param
3482         from svalue_id to const svalue *.  Add is_mutable param.
3483         (setjmp_svalue::compare_fields): Delete.
3484         (setjmp_svalue::accept): New.
3485         (setjmp_svalue::add_to_hash): Delete.
3486         (setjmp_svalue::dump_to_pp): New.
3487         (setjmp_svalue::print_details): Delete.
3488         (impl_sm_context::impl_sm_context): Drop "change" param.
3489         (impl_sm_context::get_fndecl_for_call): Drop "m_change".
3490         (impl_sm_context::on_transition): Drop ATTRIBUTE_UNUSED from
3491         "stmt" param.  Drop m_change.  Port from svalue_id to
3492         const svalue *.
3493         (impl_sm_context::warn_for_state): Drop m_change.  Port from
3494         svalue_id to const svalue *.
3495         (impl_sm_context::get_readable_tree): Rename to...
3496         (impl_sm_context::get_diagnostic_tree): ...this.  Port from
3497         svalue_id to const svalue *.
3498         (impl_sm_context::is_zero_assignment): New.
3499         (impl_sm_context::m_change): Delete field.
3500         (leak_stmt_finder::find_stmt): Handle m_var being NULL.
3501         (readability):  Increase penalty for MEM_REF.  For SSA_NAMEs,
3502         slightly favor the underlying var over the SSA name.  Heavily
3503         penalize temporaries.  Handle RESULT_DECL.
3504         (readability_comparator): Make non-static.  Consider stack depths.
3505         (impl_region_model_context::on_state_leak): Convert from svalue_id
3506         to const svalue *, updating for region_model changes.  Use
3507         id_equal.
3508         (impl_region_model_context::on_inherited_svalue): Delete.
3509         (impl_region_model_context::on_cast): Delete.
3510         (impl_region_model_context::on_condition):  Drop m_change.
3511         (impl_region_model_context::on_phi): Likewise.
3512         (impl_region_model_context::on_unexpected_tree_code): Handle t
3513         being NULL.
3514         (point_and_state::validate): Update stack checking for
3515         region_model changes.
3516         (eg_traits::dump_args_t::show_enode_details_p): New.
3517         (exploded_node::exploded_node): Initialize m_num_processed_stmts.
3518         (exploded_node::get_processed_stmt): New function.
3519         (exploded_node::get_dot_fillcolor): Add more colors.
3520         (exploded_node::dump_dot): Guard the printing of the point and
3521         state with show_enode_details_p.  Print the processed stmts for
3522         this enode after the initial state.
3523         (exploded_node::dump_to_pp): Pass true for new multiline param
3524         of program_state::dump_to_pp.
3525         (exploded_node::on_stmt): Drop "change" param.  Log the stmt.
3526         Set input_location.  Implement __analyzer_describe.  Update
3527         implementation of __analyzer_dump and __analyzer_eval.
3528         Remove purging of sm-state for unknown fncalls from here.
3529         (exploded_node::on_edge): Drop "change" param.
3530         (exploded_node::on_longjmp): Port from region_id/svalue_id to
3531         const region */const svalue *.  Call program_state::detect_leaks.
3532         Drop state_change.
3533         (exploded_node::detect_leaks): Update for changes to region_model.
3534         Call program_state::detect_leaks.
3535         (exploded_edge::exploded_edge): Drop ext_state and change params.
3536         (exploded_edge::dump_dot): "args" is no longer used.  Drop dumping
3537         of m_change.
3538         (exploded_graph::exploded_graph): Pass engine to
3539         m_diagnostic_manager ctor.  Use program_point::origin.
3540         (exploded_graph::add_function_entry):  Drop ctxt.  Use
3541         program_state::push_frame.  Drop state_change.
3542         (exploded_graph::get_or_create_node): Drop "change" param.  Add
3543         "enode_for_diag" param.  Update dumping calls for API changes.
3544         Pass point to can_merge_with_p.  Show enode indices
3545         within -Wanalyzer-too-complex diagnostic for hitting the per-point
3546         limit.
3547         (exploded_graph::add_edge): Drop "change" param.  Log which nodes
3548         are being connected.  Update for changes to exploded_edge ctor.
3549         (exploded_graph::get_per_program_point_data): New.
3550         (exploded_graph::process_worklist): Pass point to
3551         can_merge_with_p.  Drop state_change.  Update dumping call for API
3552         change.
3553         (exploded_graph::process_node):  Drop state_change.  Split the
3554         node in-place if an sm-state-change occurs.  Update
3555         m_num_processed_stmts.  Update dumping calls for API change.
3556         (exploded_graph::log_stats): Call engine::log_stats.
3557         (exploded_graph::dump_states_for_supernode): Update dumping
3558         call.
3559         (exploded_path::feasible_p): Add "eng" and "eg" params.
3560         Rename "i" to "end_idx".  Pass the manager to the region_model
3561         ctor.  Update for every processed stmt in the enode, not just the
3562         first.  Keep track of which snodes have been visited, and call
3563         loop_replay_fixup when revisiting one.
3564         (enode_label::get_text): Update dump call for new param.
3565         (exploded_graph::dump_exploded_nodes): Likewise.
3566         (exploded_graph::get_node_by_index): New.
3567         (impl_run_checkers): Create engine instance and pass its address
3568         to extrinsic_state ctor.
3569         * exploded-graph.h
3570         (impl_region_model_context::impl_region_model_context): Drop
3571         "change" params.
3572         (impl_region_model_context::void remap_svalue_ids): Delete.
3573         (impl_region_model_context::on_svalue_purge): Delete.
3574         (impl_region_model_context::on_svalue_leak): New.
3575         (impl_region_model_context::on_liveness_change): New.
3576         (impl_region_model_context::on_state_leak): Update signature.
3577         (impl_region_model_context::on_inherited_svalue): Delete.
3578         (impl_region_model_context::on_cast): Delete.
3579         (impl_region_model_context::on_unknown_change): Update signature.
3580         (impl_region_model_context::m_change): Delete.
3581         (eg_traits::dump_args_t::show_enode_details_p): New.
3582         (exploded_node::on_stmt): Drop "change" param.
3583         (exploded_node::on_edge): Likewise.
3584         (exploded_node::get_processed_stmt): New decl.
3585         (exploded_node::m_num_processed_stmts): New field.
3586         (exploded_edge::exploded_edge): Drop ext_state and change params.
3587         (exploded_edge::m_change): Delete.
3588         (exploded_graph::get_engine): New accessor.
3589         (exploded_graph::get_or_create_node): Drop "change" param.  Add
3590         "enode_for_diag" param.
3591         (exploded_graph::add_edge): Drop "change" param.
3592         (exploded_graph::get_per_program_point_data): New decl.
3593         (exploded_graph::get_node_by_index): New decl.
3594         (exploded_path::feasible_p): Add "eng" and "eg" params.
3595         * program-point.cc: Include "analyzer/store.h" before including
3596         "analyzer/region-model.h".
3597         (function_point::function_point): Move here from
3598         program-point.h.
3599         (function_point::get_function): Likewise.
3600         (function_point::from_function_entry): Likewise.
3601         (function_point::before_supernode): Likewise.
3602         (function_point::next_stmt): New function.
3603         * program-point.h (function_point::function_point): Move
3604         implementation from here to program-point.cc.
3605         (function_point::get_function): Likewise.
3606         (function_point::from_function_entry): Likewise.
3607         (function_point::before_supernode): Likewise.
3608         (function_point::next_stmt): New decl.
3609         (program_point::operator!=): New.
3610         (program_point::origin): New.
3611         (program_point::next_stmt): New.
3612         (program_point::m_function_point): Make non-const.
3613         * program-state.cc: Move includes of "analyzer/call-string.h" and
3614         "analyzer/program-point.h" to before "analyzer/region-model.h",
3615         and also include "analyzer/store.h" before it.
3616         (extrinsic_state::get_model_manager): New.
3617         (sm_state_map::sm_state_map): Pass in sm and sm_idx to ctor,
3618         rather than pass the around.
3619         (sm_state_map::clone_with_remapping): Delete.
3620         (sm_state_map::print): Remove "sm" param in favor of "m_sm".  Add
3621         "simple" and "multiline" params and support multiline vs single
3622         line dumping.
3623         (sm_state_map::dump): Remove "sm" param in favor of "m_sm".  Add
3624         "simple" param.
3625         (sm_state_map::hash): Port from svalue_id to const svalue *.
3626         (sm_state_map::operator==): Likewise.
3627         (sm_state_map::get_state): Likewise.  Call canonicalize_svalue on
3628         input.  Handle inheritance of sm-state.  Call get_default_state.
3629         (sm_state_map::get_origin): Port from svalue_id to const svalue *.
3630         (sm_state_map::set_state): Likewise.  Pass in ext_state.  Reject
3631         attempts to set state on UNKNOWN.
3632         (sm_state_map::impl_set_state): Port from svalue_id to
3633         const svalue *.  Pass in ext_state.  Call canonicalize_svalue on
3634         input.
3635         (sm_state_map::purge_for_unknown_fncall): Delete.
3636         (sm_state_map::on_svalue_leak): New.
3637         (sm_state_map::remap_svalue_ids): Delete.
3638         (sm_state_map::on_liveness_change): New.
3639         (sm_state_map::on_unknown_change): Reimplement.
3640         (sm_state_map::on_svalue_purge): Delete.
3641         (sm_state_map::on_inherited_svalue): Delete.
3642         (sm_state_map::on_cast): Delete.
3643         (sm_state_map::validate): Delete.
3644         (sm_state_map::canonicalize_svalue): New.
3645         (program_state::program_state): Update to pass manager to
3646         region_model's ctor.  Constify num_states and pass state machine
3647         and index to sm_state_map ctor.
3648         (program_state::print): Update for changes to dump API.
3649         (program_state::dump_to_pp): Ignore the summarize param.  Add
3650         "multiline" param.
3651         (program_state::dump_to_file): Add "multiline" param.
3652         (program_state::dump): Pass "true" for new "multiline" param.
3653         (program_state::push_frame): New.
3654         (program_state::on_edge): Drop "change" param.  Call
3655         program_state::detect_leaks.
3656         (program_state::prune_for_point): Add enode_for_diag param.
3657         Reimplement based on store class.  Call detect_leaks
3658         (program_state::remap_svalue_ids): Delete.
3659         (program_state::get_representative_tree): Port from svalue_id to
3660         const svalue *.
3661         (program_state::can_merge_with_p): Add "point" param.  Add early
3662         reject for sm-differences.  Drop id remapping.
3663         (program_state::validate): Drop region model and sm_state_map
3664         validation.
3665         (state_change::sm_change::dump): Delete.
3666         (state_change::sm_change::remap_svalue_ids): Delete.
3667         (state_change::sm_change::on_svalue_purge): Delete.
3668         (log_set_of_svalues): New.
3669         (state_change::sm_change::validate): Delete.
3670         (state_change::state_change): Delete.
3671         (state_change::add_sm_change): Delete.
3672         (state_change::affects_p): Delete.
3673         (state_change::dump): Delete.
3674         (state_change::remap_svalue_ids): Delete.
3675         (state_change::on_svalue_purge): Delete.
3676         (state_change::validate): Delete.
3677         (selftest::assert_dump_eq): Delete.
3678         (ASSERT_DUMP_EQ): Delete.
3679         (selftest::test_sm_state_map): Update for changes to region_model
3680         and sm_state_map, porting from svalue_id to const svalue *.
3681         (selftest::test_program_state_dumping): Likewise.  Drop test of
3682         dumping, renaming to...
3683         (selftest::test_program_state_1): ...this.
3684         (selftest::test_program_state_dumping_2): Likewise, renaming to...
3685         (selftest::test_program_state_2): ...this.
3686         (selftest::test_program_state_merging): Update for changes to
3687         region_model.
3688         (selftest::test_program_state_merging_2): Likewise.
3689         (selftest::analyzer_program_state_cc_tests): Update for renamed
3690         tests.
3691         * program-state.h (extrinsic_state::extrinsic_state): Add logger
3692         and engine params.
3693         (extrinsic_state::get_logger): New accessor.
3694         (extrinsic_state::get_engine): New accessor.
3695         (extrinsic_state::get_model_manager): New accessor.
3696         (extrinsic_state::m_logger): New field.
3697         (extrinsic_state::m_engine): New field.
3698         (struct default_hash_traits<svalue_id>): Delete.
3699         (pod_hash_traits<svalue_id>::hash): Delete.
3700         (pod_hash_traits<svalue_id>::equal): Delete.
3701         (pod_hash_traits<svalue_id>::mark_deleted): Delete.
3702         (pod_hash_traits<svalue_id>::mark_empty): Delete.
3703         (pod_hash_traits<svalue_id>::is_deleted): Delete.
3704         (pod_hash_traits<svalue_id>::is_empty): Delete.
3705         (sm_state_map::entry_t::entry_t): Port from svalue_id to
3706         const svalue *.
3707         (sm_state_map::entry_t::m_origin): Likewise.
3708         (sm_state_map::map_t): Likewise.
3709         (sm_state_map::sm_state_map): Add state_machine and index params.
3710         (sm_state_map::clone_with_remapping): Delete.
3711         (sm_state_map::print):  Drop sm param; add simple and multiline
3712         params.
3713         (sm_state_map::dump): Drop sm param; add simple param.
3714         (sm_state_map::get_state): Port from svalue_id to const svalue *.
3715         Add ext_state param.
3716         (sm_state_map::get_origin): Likewise.
3717         (sm_state_map::set_state): Likewise.
3718         (sm_state_map::impl_set_state): Likewise.
3719         (sm_state_map::purge_for_unknown_fncall): Delete.
3720         (sm_state_map::remap_svalue_ids): Delete.
3721         (sm_state_map::on_svalue_purge): Delete.
3722         (sm_state_map::on_svalue_leak): New.
3723         (sm_state_map::on_liveness_change): New.
3724         (sm_state_map::on_inherited_svalue): Delete.
3725         (sm_state_map::on_cast): Delete.
3726         (sm_state_map::validate): Delete.
3727         (sm_state_map::on_unknown_change): Port from svalue_id to
3728         const svalue *.  Add is_mutable and ext_state params.
3729         (sm_state_map::canonicalize_svalue): New.
3730         (sm_state_map::m_sm): New field.
3731         (sm_state_map::m_sm_idx): New field.
3732         (program_state::operator=): Delete.
3733         (program_state::dump_to_pp): Drop "summarize" param, adding
3734         "simple" and "multiline".
3735         (program_state::dump_to_file): Likewise.
3736         (program_state::dump): Rename "summarize" to "simple".
3737         (program_state::push_frame): New.
3738         (program_state::get_current_function): New.
3739         (program_state::on_edge): Drop "change" param.
3740         (program_state::prune_for_point): Likewise.  Add enode_for_diag
3741         param.
3742         (program_state::remap_svalue_ids): Delete.
3743         (program_state::get_representative_tree): Port from svalue_id to
3744         const svalue *.
3745         (program_state::can_purge_p): Likewise.  Pass ext_state to get_state.
3746         (program_state::can_merge_with_p): Add point param.
3747         (program_state::detect_leaks): New.
3748         (state_change_visitor::on_state_change): Port from tree and
3749         svalue_id to a pair of const svalue *.
3750         (class state_change): Delete.
3751         * region.cc: New file.
3752         * region-model-impl-calls.cc: New file.
3753         * region-model-manager.cc: New file.
3754         * region-model-reachability.cc: New file.
3755         * region-model-reachability.h: New file.
3756         * region-model.cc: Include "analyzer/call-string.h",
3757         "analyzer/program-point.h", and "analyzer/store.h" before
3758         "analyzer/region-model.h".  Include
3759         "analyzer/region-model-reachability.h".
3760         (dump_tree): Make non-static.
3761         (dump_quoted_tree): Make non-static.
3762         (print_quoted_type): Make non-static.
3763         (path_var::dump): Delete.
3764         (dump_separator): Delete.
3765         (class impl_constraint_manager): Delete.
3766         (svalue_id::print): Delete.
3767         (svalue_id::dump_node_name_to_pp): Delete.
3768         (svalue_id::validate): Delete.
3769         (region_id::print): Delete.
3770         (region_id::dump_node_name_to_pp): Delete.
3771         (region_id::validate): Delete.
3772         (region_id_set::region_id_set): Delete.
3773         (svalue_id_set::svalue_id_set): Delete.
3774         (svalue::operator==): Delete.
3775         (svalue::hash): Delete.
3776         (svalue::print): Delete.
3777         (svalue::dump_dot_to_pp): Delete.
3778         (svalue::remap_region_ids): Delete.
3779         (svalue::walk_for_canonicalization): Delete.
3780         (svalue::get_child_sid): Delete.
3781         (svalue::maybe_get_constant): Delete.
3782         (region_svalue::compare_fields): Delete.
3783         (region_svalue::add_to_hash): Delete.
3784         (region_svalue::print_details): Delete.
3785         (region_svalue::dump_dot_to_pp): Delete.
3786         (region_svalue::remap_region_ids): Delete.
3787         (region_svalue::merge_values): Delete.
3788         (region_svalue::walk_for_canonicalization): Delete.
3789         (region_svalue::eval_condition): Delete.
3790         (constant_svalue::compare_fields): Delete.
3791         (constant_svalue::add_to_hash): Delete.
3792         (constant_svalue::merge_values): Delete.
3793         (constant_svalue::eval_condition): Move to svalue.cc.
3794         (constant_svalue::print_details): Delete.
3795         (constant_svalue::get_child_sid): Delete.
3796         (unknown_svalue::compare_fields): Delete.
3797         (unknown_svalue::add_to_hash): Delete.
3798         (unknown_svalue::print_details): Delete.
3799         (poison_kind_to_str): Move to svalue.cc.
3800         (poisoned_svalue::compare_fields): Delete.
3801         (poisoned_svalue::add_to_hash): Delete.
3802         (poisoned_svalue::print_details): Delete.
3803         (region_kind_to_str): Move to region.cc and reimplement.
3804         (region::operator==): Delete.
3805         (region::get_parent_region): Delete.
3806         (region::set_value): Delete.
3807         (region::become_active_view): Delete.
3808         (region::deactivate_any_active_view): Delete.
3809         (region::deactivate_view): Delete.
3810         (region::get_value): Delete.
3811         (region::get_inherited_child_sid): Delete.
3812         (region_model::copy_region): Delete.
3813         (region_model::copy_struct_region): Delete.
3814         (region_model::copy_union_region): Delete.
3815         (region_model::copy_array_region): Delete.
3816         (region::hash): Delete.
3817         (region::print): Delete.
3818         (region::dump_dot_to_pp): Delete.
3819         (region::dump_to_pp): Delete.
3820         (region::dump_child_label): Delete.
3821         (region::validate): Delete.
3822         (region::remap_svalue_ids): Delete.
3823         (region::remap_region_ids): Delete.
3824         (region::add_view): Delete.
3825         (region::get_view): Delete.
3826         (region::region): Move to region.cc.
3827         (region::add_to_hash): Delete.
3828         (region::print_fields): Delete.
3829         (region::non_null_p): Delete.
3830         (primitive_region::clone): Delete.
3831         (primitive_region::walk_for_canonicalization): Delete.
3832         (map_region::map_region): Delete.
3833         (map_region::compare_fields): Delete.
3834         (map_region::print_fields): Delete.
3835         (map_region::validate): Delete.
3836         (map_region::dump_dot_to_pp): Delete.
3837         (map_region::dump_child_label): Delete.
3838         (map_region::get_or_create): Delete.
3839         (map_region::get): Delete.
3840         (map_region::add_to_hash): Delete.
3841         (map_region::remap_region_ids): Delete.
3842         (map_region::unbind): Delete.
3843         (map_region::get_tree_for_child_region): Delete.
3844         (map_region::get_tree_for_child_region): Delete.
3845         (tree_cmp): Move to region.cc.
3846         (map_region::can_merge_p): Delete.
3847         (map_region::walk_for_canonicalization): Delete.
3848         (map_region::get_value_by_name): Delete.
3849         (struct_or_union_region::valid_key_p): Delete.
3850         (struct_or_union_region::compare_fields): Delete.
3851         (struct_region::clone): Delete.
3852         (struct_region::compare_fields): Delete.
3853         (union_region::clone): Delete.
3854         (union_region::compare_fields): Delete.
3855         (frame_region::compare_fields): Delete.
3856         (frame_region::clone): Delete.
3857         (frame_region::valid_key_p): Delete.
3858         (frame_region::print_fields): Delete.
3859         (frame_region::add_to_hash): Delete.
3860         (globals_region::compare_fields): Delete.
3861         (globals_region::clone): Delete.
3862         (globals_region::valid_key_p): Delete.
3863         (code_region::compare_fields): Delete.
3864         (code_region::clone): Delete.
3865         (code_region::valid_key_p): Delete.
3866         (array_region::array_region): Delete.
3867         (array_region::get_element): Delete.
3868         (array_region::clone): Delete.
3869         (array_region::compare_fields): Delete.
3870         (array_region::print_fields): Delete.
3871         (array_region::validate): Delete.
3872         (array_region::dump_dot_to_pp): Delete.
3873         (array_region::dump_child_label): Delete.
3874         (array_region::get_or_create): Delete.
3875         (array_region::get): Delete.
3876         (array_region::add_to_hash): Delete.
3877         (array_region::remap_region_ids): Delete.
3878         (array_region::get_key_for_child_region): Delete.
3879         (array_region::key_cmp): Delete.
3880         (array_region::walk_for_canonicalization): Delete.
3881         (array_region::key_from_constant): Delete.
3882         (array_region::constant_from_key): Delete.
3883         (function_region::compare_fields): Delete.
3884         (function_region::clone): Delete.
3885         (function_region::valid_key_p): Delete.
3886         (stack_region::stack_region): Delete.
3887         (stack_region::compare_fields): Delete.
3888         (stack_region::clone): Delete.
3889         (stack_region::print_fields): Delete.
3890         (stack_region::dump_child_label): Delete.
3891         (stack_region::validate): Delete.
3892         (stack_region::push_frame): Delete.
3893         (stack_region::get_current_frame_id): Delete.
3894         (stack_region::pop_frame): Delete.
3895         (stack_region::add_to_hash): Delete.
3896         (stack_region::remap_region_ids): Delete.
3897         (stack_region::can_merge_p): Delete.
3898         (stack_region::walk_for_canonicalization): Delete.
3899         (stack_region::get_value_by_name): Delete.
3900         (heap_region::heap_region): Delete.
3901         (heap_region::compare_fields): Delete.
3902         (heap_region::clone): Delete.
3903         (heap_region::walk_for_canonicalization): Delete.
3904         (root_region::root_region): Delete.
3905         (root_region::compare_fields): Delete.
3906         (root_region::clone): Delete.
3907         (root_region::print_fields): Delete.
3908         (root_region::validate): Delete.
3909         (root_region::dump_child_label): Delete.
3910         (root_region::push_frame): Delete.
3911         (root_region::get_current_frame_id): Delete.
3912         (root_region::pop_frame): Delete.
3913         (root_region::ensure_stack_region): Delete.
3914         (root_region::get_stack_region): Delete.
3915         (root_region::ensure_globals_region): Delete.
3916         (root_region::get_code_region): Delete.
3917         (root_region::ensure_code_region): Delete.
3918         (root_region::get_globals_region): Delete.
3919         (root_region::ensure_heap_region): Delete.
3920         (root_region::get_heap_region): Delete.
3921         (root_region::remap_region_ids): Delete.
3922         (root_region::can_merge_p): Delete.
3923         (root_region::add_to_hash): Delete.
3924         (root_region::walk_for_canonicalization): Delete.
3925         (root_region::get_value_by_name): Delete.
3926         (symbolic_region::symbolic_region): Delete.
3927         (symbolic_region::compare_fields): Delete.
3928         (symbolic_region::clone): Delete.
3929         (symbolic_region::walk_for_canonicalization): Delete.
3930         (symbolic_region::print_fields): Delete.
3931         (region_model::region_model): Add region_model_manager * param.
3932         Reimplement in terms of store, dropping impl_constraint_manager
3933         subclass.
3934         (region_model::operator=): Reimplement in terms of store
3935         (region_model::operator==): Likewise.
3936         (region_model::hash): Likewise.
3937         (region_model::print): Delete.
3938         (region_model::print_svalue): Delete.
3939         (region_model::dump_dot_to_pp): Delete.
3940         (region_model::dump_dot_to_file): Delete.
3941         (region_model::dump_dot): Delete.
3942         (region_model::dump_to_pp): Replace "summarize" param with
3943         "simple" and "multiline".  Port to store-based implementation.
3944         (region_model::dump): Replace "summarize" param with "simple" and
3945         "multiline".
3946         (dump_vec_of_tree): Delete.
3947         (region_model::dump_summary_of_rep_path_vars): Delete.
3948         (region_model::validate): Delete.
3949         (svalue_id_cmp_by_constant_svalue_model): Delete.
3950         (svalue_id_cmp_by_constant_svalue): Delete.
3951         (region_model::canonicalize): Drop "ctxt" param.  Reimplement in
3952         terms of store and constraints.
3953         (region_model::canonicalized_p): Remove NULL arg to canonicalize.
3954         (region_model::loop_replay_fixup): New.
3955         (poisoned_value_diagnostic::emit): Tweak wording of warnings.
3956         (region_model::check_for_poison): Delete.
3957         (region_model::get_gassign_result): New.
3958         (region_model::on_assignment): Port to store-based implementation.
3959         (region_model::on_call_pre): Delete calls to check_for_poison.
3960         Move implementations to region-model-impl-calls.c and port to
3961         store-based implementation.
3962         (region_model::on_call_post): Likewise.
3963         (class reachable_regions): Move to region-model-reachability.h/cc
3964         and port to store-based implementation.
3965         (region_model::handle_unrecognized_call): Port to store-based
3966         implementation.
3967         (region_model::get_reachable_svalues): New.
3968         (region_model::on_setjmp): Port to store-based implementation.
3969         (region_model::on_longjmp): Likewise.
3970         (region_model::handle_phi): Drop is_back_edge param and the logic
3971         using it.
3972         (region_model::get_lvalue_1): Port from region_id to const region *.
3973         (region_model::make_region_for_unexpected_tree_code): Delete.
3974         (assert_compat_types): If the check fails, use internal_error to
3975         show the types.
3976         (region_model::get_lvalue): Port from region_id to const region *.
3977         (region_model::get_rvalue_1): Port from svalue_id to const svalue *.
3978         (region_model::get_rvalue): Likewise.
3979         (region_model::get_or_create_ptr_svalue): Delete.
3980         (region_model::get_or_create_constant_svalue): Delete.
3981         (region_model::get_svalue_for_fndecl): Delete.
3982         (region_model::get_region_for_fndecl): Delete.
3983         (region_model::get_svalue_for_label): Delete.
3984         (region_model::get_region_for_label): Delete.
3985         (build_cast): Delete.
3986         (region_model::maybe_cast_1): Delete.
3987         (region_model::maybe_cast): Delete.
3988         (region_model::get_field_region): Delete.
3989         (region_model::get_store_value): New.
3990         (region_model::region_exists_p): New.
3991         (region_model::deref_rvalue): Port from svalue_id to const svalue *.
3992         (region_model::set_value): Likewise.
3993         (region_model::clobber_region): New.
3994         (region_model::purge_region): New.
3995         (region_model::zero_fill_region): New.
3996         (region_model::mark_region_as_unknown): New.
3997         (region_model::eval_condition): Port from svalue_id to
3998         const svalue *.
3999         (region_model::eval_condition_without_cm): Likewise.
4000         (region_model::compare_initial_and_pointer): New.
4001         (region_model::add_constraint): Port from svalue_id to
4002         const svalue *.
4003         (region_model::maybe_get_constant): Delete.
4004         (region_model::get_representative_path_var): New.
4005         (region_model::add_new_malloc_region): Delete.
4006         (region_model::get_representative_tree): Port to const svalue *.
4007         (region_model::get_representative_path_var): Port to
4008         const region *.
4009         (region_model::get_path_vars_for_svalue): Delete.
4010         (region_model::set_to_new_unknown_value): Delete.
4011         (region_model::update_for_phis): Don't pass is_back_edge to handle_phi.
4012         (region_model::update_for_call_superedge): Port from svalue_id to
4013         const svalue *.
4014         (region_model::update_for_return_superedge): Port to store-based
4015         implementation.
4016         (region_model::update_for_call_summary): Replace
4017         set_to_new_unknown_value with mark_region_as_unknown.
4018         (region_model::get_root_region): Delete.
4019         (region_model::get_stack_region_id): Delete.
4020         (region_model::push_frame): Delete.
4021         (region_model::get_current_frame_id): Delete.
4022         (region_model::get_current_function): Delete.
4023         (region_model::pop_frame): Delete.
4024         (region_model::on_top_level_param): New.
4025         (region_model::get_stack_depth): Delete.
4026         (region_model::get_function_at_depth): Delete.
4027         (region_model::get_globals_region_id): Delete.
4028         (region_model::add_svalue): Delete.
4029         (region_model::replace_svalue): Delete.
4030         (region_model::add_region): Delete.
4031         (region_model::get_svalue): Delete.
4032         (region_model::get_region): Delete.
4033         (make_region_for_type): Delete.
4034         (region_model::add_region_for_type): Delete.
4035         (region_model::on_top_level_param): New.
4036         (class restrict_to_used_svalues): Delete.
4037         (region_model::purge_unused_svalues): Delete.
4038         (region_model::push_frame): New.
4039         (region_model::remap_svalue_ids): Delete.
4040         (region_model::remap_region_ids): Delete.
4041         (region_model::purge_regions): Delete.
4042         (region_model::get_descendents): Delete.
4043         (region_model::delete_region_and_descendents): Delete.
4044         (region_model::poison_any_pointers_to_bad_regions): Delete.
4045         (region_model::can_merge_with_p): Delete.
4046         (region_model::get_current_function): New.
4047         (region_model::get_value_by_name): Delete.
4048         (region_model::convert_byte_offset_to_array_index): Delete.
4049         (region_model::pop_frame): New.
4050         (region_model::get_or_create_mem_ref): Delete.
4051         (region_model::get_stack_depth): New.
4052         (region_model::get_frame_at_index): New.
4053         (region_model::unbind_region_and_descendents): New.
4054         (struct bad_pointer_finder): New.
4055         (region_model::get_or_create_pointer_plus_expr): Delete.
4056         (region_model::poison_any_pointers_to_descendents): New.
4057         (region_model::get_or_create_view): Delete.
4058         (region_model::can_merge_with_p): New.
4059         (region_model::get_fndecl_for_call):  Port from svalue_id to
4060         const svalue *.
4061         (struct append_ssa_names_cb_data): New.
4062         (get_ssa_name_regions_for_current_frame): New.
4063         (region_model::append_ssa_names_cb): New.
4064         (model_merger::dump_to_pp): Add "simple" param.  Drop dumping of
4065         remappings.
4066         (model_merger::dump): Add "simple" param to both overloads.
4067         (model_merger::can_merge_values_p): Delete.
4068         (model_merger::record_regions): Delete.
4069         (model_merger::record_svalues): Delete.
4070         (svalue_id_merger_mapping::svalue_id_merger_mapping): Delete.
4071         (svalue_id_merger_mapping::dump_to_pp): Delete.
4072         (svalue_id_merger_mapping::dump): Delete.
4073         (region_model::create_region_for_heap_alloc): New.
4074         (region_model::create_region_for_alloca): New.
4075         (region_model::record_dynamic_extents): New.
4076         (canonicalization::canonicalization): Delete.
4077         (canonicalization::walk_rid): Delete.
4078         (canonicalization::walk_sid): Delete.
4079         (canonicalization::dump_to_pp): Delete.
4080         (canonicalization::dump): Delete.
4081         (inchash::add): Delete overloads for svalue_id and region_id.
4082         (engine::log_stats): New.
4083         (assert_condition): Add overload comparing svalues.
4084         (assert_dump_eq): Pass "true" for multiline.
4085         (selftest::test_dump): Update for rewrite of region_model.
4086         (selftest::test_dump_2): Rename to...
4087         (selftest::test_struct): ...this.  Provide a region_model_manager
4088         when creating region_model instance.  Remove dump test.  Add
4089         checks for get_offset.
4090         (selftest::test_dump_3): Rename to...
4091         (selftest::test_array_1): ...this.  Provide a region_model_manager
4092         when creating region_model instance.  Remove dump test.
4093         (selftest::test_get_representative_tree): Port from svalue_id to
4094         new API.  Add test coverage for various expressions.
4095         (selftest::test_unique_constants): Provide a region_model_manager
4096         for the region_model.  Add test coverage for comparing const vs
4097         non-const.
4098         (selftest::test_svalue_equality): Delete.
4099         (selftest::test_region_equality): Delete.
4100         (selftest::test_unique_unknowns): New.
4101         (class purge_all_svalue_ids): Delete.
4102         (class purge_one_svalue_id): Delete.
4103         (selftest::test_purging_by_criteria): Delete.
4104         (selftest::test_initial_svalue_folding): New.
4105         (selftest::test_unaryop_svalue_folding): New.
4106         (selftest::test_binop_svalue_folding): New.
4107         (selftest::test_sub_svalue_folding): New.
4108         (selftest::test_purge_unused_svalues): Delete.
4109         (selftest::test_descendent_of_p): New.
4110         (selftest::test_assignment): Provide a region_model_manager for
4111         the region_model.  Drop the dump test.
4112         (selftest::test_compound_assignment): Likewise.
4113         (selftest::test_stack_frames): Port to new implementation.
4114         (selftest::test_get_representative_path_var): Likewise.
4115         (selftest::test_canonicalization_1): Rename to...
4116         (selftest::test_equality_1): ...this.  Port to new API, and add
4117         (selftest::test_canonicalization_2): Provide a
4118         region_model_manager when creating region_model instances.
4119         Remove redundant canicalization.
4120         (selftest::test_canonicalization_3): Provide a
4121         region_model_manager when creating region_model instances.
4122         Remove param from calls to region_model::canonicalize.
4123         (selftest::test_canonicalization_4): Likewise.
4124         (selftest::assert_region_models_merge): Constify
4125         out_merged_svalue.  Port to new API.
4126         (selftest::test_state_merging): Provide a
4127         region_model_manager when creating region_model instances.
4128         Provide a program_point point when merging them.  Replace
4129         set_to_new_unknown_value with usage of placeholder_svalues.
4130         Drop get_value_by_name.  Port from svalue_id to const svalue *.
4131         Add test of heap allocation.
4132         (selftest::test_constraint_merging):  Provide a
4133         region_model_manager when creating region_model instances.
4134         Provide a program_point point when merging them.  Eliminate use
4135         of set_to_new_unknown_value.
4136         (selftest::test_widening_constraints): New.
4137         (selftest::test_iteration_1): New.
4138         (selftest::test_malloc_constraints): Port to store-based
4139         implementation.
4140         (selftest::test_var): New test.
4141         (selftest::test_array_2): New test.
4142         (selftest::test_mem_ref): New test.
4143         (selftest::test_POINTER_PLUS_EXPR_then_MEM_REF): New.
4144         (selftest::test_malloc): New.
4145         (selftest::test_alloca): New.
4146         (selftest::analyzer_region_model_cc_tests): Update for renamings.
4147         Call new functions.
4148         * region-model.h (class path_var): Move to analyzer.h.
4149         (class svalue_id): Delete.
4150         (class region_id): Delete.
4151         (class id_map): Delete.
4152         (svalue_id_map): Delete.
4153         (region_id_map): Delete.
4154         (id_map<T>::id_map): Delete.
4155         (id_map<T>::put): Delete.
4156         (id_map<T>::get_dst_for_src): Delete.
4157         (id_map<T>::get_src_for_dst): Delete.
4158         (id_map<T>::dump_to_pp): Delete.
4159         (id_map<T>::dump): Delete.
4160         (id_map<T>::update): Delete.
4161         (one_way_svalue_id_map): Delete.
4162         (one_way_region_id_map): Delete.
4163         (class region_id_set): Delete.
4164         (class svalue_id_set): Delete.
4165         (struct complexity): New.
4166         (class visitor): New.
4167         (enum svalue_kind): Add SK_SETJMP, SK_INITIAL, SK_UNARYOP,
4168         SK_BINOP, SK_SUB,SK_UNMERGEABLE, SK_PLACEHOLDER, SK_WIDENING,
4169         SK_COMPOUND, and SK_CONJURED.
4170         (svalue::operator==): Delete.
4171         (svalue::operator!=): Delete.
4172         (svalue::clone): Delete.
4173         (svalue::hash): Delete.
4174         (svalue::dump_dot_to_pp): Delete.
4175         (svalue::dump_to_pp): New.
4176         (svalue::dump): New.
4177         (svalue::get_desc): New.
4178         (svalue::dyn_cast_initial_svalue): New.
4179         (svalue::dyn_cast_unaryop_svalue): New.
4180         (svalue::dyn_cast_binop_svalue): New.
4181         (svalue::dyn_cast_sub_svalue): New.
4182         (svalue::dyn_cast_unmergeable_svalue): New.
4183         (svalue::dyn_cast_widening_svalue): New.
4184         (svalue::dyn_cast_compound_svalue): New.
4185         (svalue::dyn_cast_conjured_svalue): New.
4186         (svalue::maybe_undo_cast): New.
4187         (svalue::unwrap_any_unmergeable): New.
4188         (svalue::remap_region_ids): Delete
4189         (svalue::can_merge_p): New.
4190         (svalue::walk_for_canonicalization): Delete
4191         (svalue::get_complexity): New.
4192         (svalue::get_child_sid): Delete
4193         (svalue::accept): New.
4194         (svalue::live_p): New.
4195         (svalue::implicitly_live_p): New.
4196         (svalue::svalue): Add complexity param.
4197         (svalue::add_to_hash): Delete
4198         (svalue::print_details): Delete
4199         (svalue::m_complexity): New field.
4200         (region_svalue::key_t): New struct.
4201         (region_svalue::region_svalue): Port from region_id to
4202         const region_id *.  Add complexity.
4203         (region_svalue::compare_fields): Delete.
4204         (region_svalue::clone): Delete.
4205         (region_svalue::dump_dot_to_pp): Delete.
4206         (region_svalue::get_pointee): Port from region_id to
4207         const region_id *.
4208         (region_svalue::remap_region_ids): Delete.
4209         (region_svalue::merge_values): Delete.
4210         (region_svalue::dump_to_pp): New.
4211         (region_svalue::accept): New.
4212         (region_svalue::walk_for_canonicalization): Delete.
4213         (region_svalue::eval_condition): Make params const.
4214         (region_svalue::add_to_hash): Delete.
4215         (region_svalue::print_details): Delete.
4216         (region_svalue::m_rid): Replace with...
4217         (region_svalue::m_reg): ...this.
4218         (is_a_helper <region_svalue *>::test): Convert to...
4219         (is_a_helper <const region_svalue *>::test): ...this.
4220         (template <> struct default_hash_traits<region_svalue::key_t>):
4221         New.
4222         (constant_svalue::constant_svalue): Add complexity.
4223         (constant_svalue::compare_fields): Delete.
4224         (constant_svalue::clone): Delete.
4225         (constant_svalue::add_to_hash): Delete.
4226         (constant_svalue::dump_to_pp): New.
4227         (constant_svalue::accept): New.
4228         (constant_svalue::implicitly_live_p): New.
4229         (constant_svalue::merge_values): Delete.
4230         (constant_svalue::eval_condition): Make params const.
4231         (constant_svalue::get_child_sid): Delete.
4232         (constant_svalue::print_details): Delete.
4233         (is_a_helper <constant_svalue *>::test): Convert to...
4234         (is_a_helper <const constant_svalue *>::test): ...this.
4235         (class unknown_svalue): Update leading comment.
4236         (unknown_svalue::unknown_svalue): Add complexity.
4237         (unknown_svalue::compare_fields): Delete.
4238         (unknown_svalue::add_to_hash): Delete.
4239         (unknown_svalue::dyn_cast_unknown_svalue): Delete.
4240         (unknown_svalue::print_details): Delete.
4241         (unknown_svalue::dump_to_pp): New.
4242         (unknown_svalue::accept): New.
4243         (poisoned_svalue::key_t): New struct.
4244         (poisoned_svalue::poisoned_svalue): Add complexity.
4245         (poisoned_svalue::compare_fields): Delete.
4246         (poisoned_svalue::clone): Delete.
4247         (poisoned_svalue::add_to_hash): Delete.
4248         (poisoned_svalue::dump_to_pp): New.
4249         (poisoned_svalue::accept): New.
4250         (poisoned_svalue::print_details): Delete.
4251         (is_a_helper <poisoned_svalue *>::test): Convert to...
4252         (is_a_helper <const poisoned_svalue *>::test): ...this.
4253         (template <> struct default_hash_traits<poisoned_svalue::key_t>):
4254         New.
4255         (setjmp_record::add_to_hash): New.
4256         (setjmp_svalue::key_t): New struct.
4257         (setjmp_svalue::compare_fields): Delete.
4258         (setjmp_svalue::clone): Delete.
4259         (setjmp_svalue::add_to_hash): Delete.
4260         (setjmp_svalue::setjmp_svalue): Add complexity.
4261         (setjmp_svalue::dump_to_pp): New.
4262         (setjmp_svalue::accept): New.
4263         (setjmp_svalue::void print_details): Delete.
4264         (is_a_helper <const setjmp_svalue *>::test): New.
4265         (template <> struct default_hash_traits<setjmp_svalue::key_t>): New.
4266         (class initial_svalue : public svalue): New.
4267         (is_a_helper <const initial_svalue *>::test): New.
4268         (class unaryop_svalue): New.
4269         (is_a_helper <const unaryop_svalue *>::test): New.
4270         (template <> struct default_hash_traits<unaryop_svalue::key_t>): New.
4271         (class binop_svalue): New.
4272         (is_a_helper <const binop_svalue *>::test): New.
4273         (template <> struct default_hash_traits<binop_svalue::key_t>): New.
4274         (class sub_svalue): New.
4275         (is_a_helper <const sub_svalue *>::test): New.
4276         (template <> struct default_hash_traits<sub_svalue::key_t>): New.
4277         (class unmergeable_svalue): New.
4278         (is_a_helper <const unmergeable_svalue *>::test): New.
4279         (class placeholder_svalue): New.
4280         (is_a_helper <placeholder_svalue *>::test): New.
4281         (class widening_svalue): New.
4282         (is_a_helper <widening_svalue *>::test): New.
4283         (template <> struct default_hash_traits<widening_svalue::key_t>): New.
4284         (class compound_svalue): New.
4285         (is_a_helper <compound_svalue *>::test): New.
4286         (template <> struct default_hash_traits<compound_svalue::key_t>): New.
4287         (class conjured_svalue): New.
4288         (is_a_helper <conjured_svalue *>::test): New.
4289         (template <> struct default_hash_traits<conjured_svalue::key_t>): New.
4290         (enum region_kind): Delete RK_PRIMITIVE, RK_STRUCT, RK_UNION, and
4291         RK_ARRAY.  Add RK_LABEL, RK_DECL, RK_FIELD, RK_ELEMENT, RK_OFFSET,
4292         RK_CAST, RK_HEAP_ALLOCATED, RK_ALLOCA, RK_STRING, and RK_UNKNOWN.
4293         (region_kind_to_str): Delete.
4294         (region::~region): Move implementation to region.cc.
4295         (region::operator==): Delete.
4296         (region::operator!=): Delete.
4297         (region::clone): Delete.
4298         (region::get_id): New.
4299         (region::cmp_ids): New.
4300         (region::dyn_cast_map_region): Delete.
4301         (region::dyn_cast_array_region): Delete.
4302         (region::region_id get_parent): Delete.
4303         (region::get_parent_region): Convert to a simple accessor.
4304         (region::void set_value): Delete.
4305         (region::svalue_id get_value): Delete.
4306         (region::svalue_id get_value_direct): Delete.
4307         (region::svalue_id get_inherited_child_sid): Delete.
4308         (region::dyn_cast_frame_region): New.
4309         (region::dyn_cast_function_region): New.
4310         (region::dyn_cast_decl_region): New.
4311         (region::dyn_cast_field_region): New.
4312         (region::dyn_cast_element_region): New.
4313         (region::dyn_cast_offset_region): New.
4314         (region::dyn_cast_cast_region): New.
4315         (region::dyn_cast_string_region): New.
4316         (region::accept): New.
4317         (region::get_base_region): New.
4318         (region::base_region_p): New.
4319         (region::descendent_of_p): New.
4320         (region::maybe_get_frame_region): New.
4321         (region::maybe_get_decl): New.
4322         (region::hash): Delete.
4323         (region::rint): Delete.
4324         (region::dump_dot_to_pp): Delete.
4325         (region::get_desc): New.
4326         (region::dump_to_pp): Convert to vfunc, changing signature.
4327         (region::dump_child_label): Delete.
4328         (region::remap_svalue_ids): Delete.
4329         (region::remap_region_ids): Delete.
4330         (region::dump): New.
4331         (region::walk_for_canonicalization): Delete.
4332         (region::non_null_p): Drop region_model param.
4333         (region::add_view): Delete.
4334         (region::get_view): Delete.
4335         (region::get_active_view): Delete.
4336         (region::is_view_p): Delete.
4337         (region::cmp_ptrs): New.
4338         (region::validate): Delete.
4339         (region::get_offset): New.
4340         (region::get_byte_size): New.
4341         (region::get_bit_size): New.
4342         (region::get_subregions_for_binding): New.
4343         (region::region): Add complexity param.  Convert parent from
4344         region_id to const region *.  Drop svalue_id.  Drop copy ctor.
4345         (region::symbolic_for_unknown_ptr_p): New.
4346         (region::add_to_hash): Delete.
4347         (region::print_fields): Delete.
4348         (region::get_complexity): New accessor.
4349         (region::become_active_view): Delete.
4350         (region::deactivate_any_active_view): Delete.
4351         (region::deactivate_view): Delete.
4352         (region::calc_offset): New.
4353         (region::m_parent_rid): Delete.
4354         (region::m_sval_id): Delete.
4355         (region::m_complexity): New.
4356         (region::m_id): New.
4357         (region::m_parent): New.
4358         (region::m_view_rids): Delete.
4359         (region::m_is_view): Delete.
4360         (region::m_active_view_rid): Delete.
4361         (region::m_cached_offset): New.
4362         (is_a_helper <region *>::test): Convert to...
4363         (is_a_helper <const region *>::test): ... this.
4364         (class primitive_region): Delete.
4365         (class space_region): New.
4366         (class map_region): Delete.
4367         (is_a_helper <map_region *>::test): Delete.
4368         (class frame_region): Reimplement.
4369         (template <> struct default_hash_traits<frame_region::key_t>):
4370         New.
4371         (class globals_region): Reimplement.
4372         (is_a_helper <globals_region *>::test): Convert to...
4373         (is_a_helper <const globals_region *>::test): ...this.
4374         (class struct_or_union_region): Delete.
4375         (is_a_helper <struct_or_union_region *>::test): Delete.
4376         (class code_region): Reimplement.
4377         (is_a_helper <const code_region *>::test): New.
4378         (class struct_region): Delete.
4379         (is_a_helper <struct_region *>::test): Delete.
4380         (class function_region): Reimplement.
4381         (is_a_helper <function_region *>::test): Convert to...
4382         (is_a_helper <const function_region *>::test): ...this.
4383         (class union_region): Delete.
4384         (is_a_helper <union_region *>::test): Delete.
4385         (class label_region): New.
4386         (is_a_helper <const label_region *>::test): New.
4387         (class scope_region): Delete.
4388         (class stack_region): Reimplement.
4389         (is_a_helper <stack_region *>::test): Convert to...
4390         (is_a_helper <const stack_region *>::test): ...this.
4391         (class heap_region): Reimplement.
4392         (is_a_helper <heap_region *>::test): Convert to...
4393         (is_a_helper <const heap_region *>::test): ...this.
4394         (class root_region): Reimplement.
4395         (is_a_helper <root_region *>::test): Convert to...
4396         (is_a_helper <const root_region *>::test): ...this.
4397         (class symbolic_region): Reimplement.
4398         (is_a_helper <const symbolic_region *>::test): New.
4399         (template <> struct default_hash_traits<symbolic_region::key_t>):
4400         New.
4401         (class decl_region): New.
4402         (is_a_helper <const decl_region *>::test): New.
4403         (class field_region): New.
4404         (template <> struct default_hash_traits<field_region::key_t>): New.
4405         (class array_region): Delete.
4406         (class element_region): New.
4407         (is_a_helper <array_region *>::test): Delete.
4408         (is_a_helper <const element_region *>::test): New.
4409         (template <> struct default_hash_traits<element_region::key_t>):
4410         New.
4411         (class offset_region): New.
4412         (is_a_helper <const offset_region *>::test): New.
4413         (template <> struct default_hash_traits<offset_region::key_t>):
4414         New.
4415         (class cast_region): New.
4416         (is_a_helper <const cast_region *>::test): New.
4417         (template <> struct default_hash_traits<cast_region::key_t>): New.
4418         (class heap_allocated_region): New.
4419         (class alloca_region): New.
4420         (class string_region): New.
4421         (is_a_helper <const string_region *>::test): New.
4422         (class unknown_region): New.
4423         (class region_model_manager): New.
4424         (struct append_ssa_names_cb_data): New.
4425         (class call_details): New.
4426         (region_model::region_model): Add region_model_manager param.
4427         (region_model::print_svalue): Delete.
4428         (region_model::dump_dot_to_pp): Delete.
4429         (region_model::dump_dot_to_file): Delete.
4430         (region_model::dump_dot): Delete.
4431         (region_model::dump_to_pp): Drop summarize param in favor of
4432         simple and multiline.
4433         (region_model::dump): Likewise.
4434         (region_model::summarize_to_pp): Delete.
4435         (region_model::summarize): Delete.
4436         (region_model::void canonicalize): Drop ctxt param.
4437         (region_model::void check_for_poison): Delete.
4438         (region_model::get_gassign_result): New.
4439         (region_model::impl_call_alloca): New.
4440         (region_model::impl_call_analyzer_describe): New.
4441         (region_model::impl_call_analyzer_eval): New.
4442         (region_model::impl_call_builtin_expect): New.
4443         (region_model::impl_call_calloc): New.
4444         (region_model::impl_call_free): New.
4445         (region_model::impl_call_malloc): New.
4446         (region_model::impl_call_memset): New.
4447         (region_model::impl_call_strlen): New.
4448         (region_model::get_reachable_svalues): New.
4449         (region_model::handle_phi): Drop is_back_edge param.
4450         (region_model::region_id get_root_rid): Delete.
4451         (region_model::root_region *get_root_region): Delete.
4452         (region_model::region_id get_stack_region_id): Delete.
4453         (region_model::push_frame): Convert from region_id and svalue_id
4454         to const region * and const svalue *.
4455         (region_model::get_current_frame_id): Replace with...
4456         (region_model::get_current_frame): ...this.
4457         (region_model::pop_frame): Convert from region_id to
4458         const region *.  Drop purge and stats param.  Add out_result.
4459         (region_model::function *get_function_at_depth): Delete.
4460         (region_model::get_globals_region_id): Delete.
4461         (region_model::add_svalue): Delete.
4462         (region_model::replace_svalue): Delete.
4463         (region_model::add_region): Delete.
4464         (region_model::add_region_for_type): Delete.
4465         (region_model::get_svalue): Delete.
4466         (region_model::get_region): Delete.
4467         (region_model::get_lvalue): Convert from region_id to
4468         const region *.
4469         (region_model::get_rvalue): Convert from svalue_id to
4470         const svalue *.
4471         (region_model::get_or_create_ptr_svalue): Delete.
4472         (region_model::get_or_create_constant_svalue): Delete.
4473         (region_model::get_svalue_for_fndecl): Delete.
4474         (region_model::get_svalue_for_label): Delete.
4475         (region_model::get_region_for_fndecl): Delete.
4476         (region_model::get_region_for_label): Delete.
4477         (region_model::get_frame_at_index (int index) const;): New.
4478         (region_model::maybe_cast): Delete.
4479         (region_model::maybe_cast_1): Delete.
4480         (region_model::get_field_region): Delete.
4481         (region_model::id deref_rvalue): Convert from region_id and
4482         svalue_id to const region * and const svalue *.  Drop overload,
4483         passing in both a tree and an svalue.
4484         (region_model::set_value): Convert from region_id and svalue_id to
4485         const region * and const svalue *.
4486         (region_model::set_to_new_unknown_value): Delete.
4487         (region_model::clobber_region (const region *reg);): New.
4488         (region_model::purge_region (const region *reg);): New.
4489         (region_model::zero_fill_region (const region *reg);): New.
4490         (region_model::mark_region_as_unknown (const region *reg);): New.
4491         (region_model::copy_region): Convert from region_id to
4492         const region *.
4493         (region_model::eval_condition): Convert from svalue_id to
4494         const svalue *.
4495         (region_model::eval_condition_without_cm): Likewise.
4496         (region_model::compare_initial_and_pointer): New.
4497         (region_model:maybe_get_constant): Delete.
4498         (region_model::add_new_malloc_region): Delete.
4499         (region_model::get_representative_tree): Convert from svalue_id to
4500         const svalue *.
4501         (region_model::get_representative_path_var): Delete decl taking a
4502         region_id in favor of two decls, for svalue vs region, with an
4503         svalue_set to ensure termination.
4504         (region_model::get_path_vars_for_svalue): Delete.
4505         (region_model::create_region_for_heap_alloc): New.
4506         (region_model::create_region_for_alloca): New.
4507         (region_model::purge_unused_svalues): Delete.
4508         (region_model::remap_svalue_ids): Delete.
4509         (region_model::remap_region_ids): Delete.
4510         (region_model::purge_regions): Delete.
4511         (region_model::get_num_svalues): Delete.
4512         (region_model::get_num_regions): Delete.
4513         (region_model::get_descendents): Delete.
4514         (region_model::get_store): New.
4515         (region_model::delete_region_and_descendents): Delete.
4516         (region_model::get_manager): New.
4517         (region_model::unbind_region_and_descendents): New.
4518         (region_model::can_merge_with_p): Add point param.  Drop
4519         svalue_id_merger_mapping.
4520         (region_model::get_value_by_name): Delete.
4521         (region_model::convert_byte_offset_to_array_index): Delete.
4522         (region_model::get_or_create_mem_ref): Delete.
4523         (region_model::get_or_create_pointer_plus_expr): Delete.
4524         (region_model::get_or_create_view): Delete.
4525         (region_model::get_lvalue_1): Convert from region_id to
4526         const region *.
4527         (region_model::get_rvalue_1): Convert from svalue_id to
4528         const svalue *.
4529         (region_model::get_ssa_name_regions_for_current_frame): New.
4530         (region_model::append_ssa_names_cb): New.
4531         (region_model::get_store_value): New.
4532         (region_model::copy_struct_region): Delete.
4533         (region_model::copy_union_region): Delete.
4534         (region_model::copy_array_region): Delete.
4535         (region_model::region_exists_p): New.
4536         (region_model::make_region_for_unexpected_tree_code): Delete.
4537         (region_model::loop_replay_fixup): New.
4538         (region_model::poison_any_pointers_to_bad_regions): Delete.
4539         (region_model::poison_any_pointers_to_descendents): New.
4540         (region_model::dump_summary_of_rep_path_vars): Delete.
4541         (region_model::on_top_level_param): New.
4542         (region_model::record_dynamic_extents): New.
4543         (region_model::m_mgr;): New.
4544         (region_model::m_store;): New.
4545         (region_model::m_svalues;): Delete.
4546         (region_model::m_regions;): Delete.
4547         (region_model::m_root_rid;): Delete.
4548         (region_model::m_current_frame;): New.
4549         (region_model_context::remap_svalue_ids): Delete.
4550         (region_model_context::can_purge_p): Delete.
4551         (region_model_context::on_svalue_leak): New.
4552         (region_model_context::on_svalue_purge): Delete.
4553         (region_model_context::on_liveness_change): New.
4554         (region_model_context::on_inherited_svalue): Delete.
4555         (region_model_context::on_cast): Delete.
4556         (region_model_context::on_unknown_change): Convert from svalue_id to
4557         const svalue * and add is_mutable.
4558         (class noop_region_model_context): Update for region_model_context
4559         changes.
4560         (model_merger::model_merger): Add program_point.  Drop
4561         svalue_id_merger_mapping.
4562         (model_merger::dump_to_pp): Add "simple" param.
4563         (model_merger::dump): Likewise.
4564         (model_merger::get_region_a): Delete.
4565         (model_merger::get_region_b): Delete.
4566         (model_merger::can_merge_values_p): Delete.
4567         (model_merger::record_regions): Delete.
4568         (model_merger::record_svalues): Delete.
4569         (model_merger::m_point): New field.
4570         (model_merger::m_map_regions_from_a_to_m): Delete.
4571         (model_merger::m_map_regions_from_b_to_m): Delete.
4572         (model_merger::m_sid_mapping): Delete.
4573         (struct svalue_id_merger_mapping): Delete.
4574         (class engine): New.
4575         (struct canonicalization): Delete.
4576         (inchash::add): Delete decls for hashing svalue_id and region_id.
4577         (test_region_model_context::on_unexpected_tree_code): Require t to
4578         be non-NULL.
4579         (selftest::assert_condition): Add overload comparing a pair of
4580         const svalue *.
4581         * sm-file.cc: Include "tristate.h", "selftest.h",
4582         "analyzer/call-string.h", "analyzer/program-point.h",
4583         "analyzer/store.h", and "analyzer/region-model.h".
4584         (fileptr_state_machine::get_default_state): New.
4585         (fileptr_state_machine::on_stmt): Remove calls to
4586         get_readable_tree in favor of get_diagnostic_tree.
4587         * sm-malloc.cc: Include "tristate.h", "selftest.h",
4588         "analyzer/call-string.h", "analyzer/program-point.h",
4589         "analyzer/store.h", and "analyzer/region-model.h".
4590         (malloc_state_machine::get_default_state): New.
4591         (malloc_state_machine::reset_when_passed_to_unknown_fn_p): New.
4592         (malloc_diagnostic::describe_state_change): Handle change.m_expr
4593         being NULL.
4594         (null_arg::emit): Avoid printing "NULL '0'".
4595         (null_arg::describe_final_event): Avoid printing "(0) NULL".
4596         (malloc_leak::emit): Handle m_arg being NULL.
4597         (malloc_leak::describe_final_event): Handle ev.m_expr being NULL.
4598         (malloc_state_machine::on_stmt): Don't call get_readable_tree.
4599         Call get_diagnostic_tree when creating pending diagnostics.
4600         Update for is_zero_assignment becoming a member function of
4601         sm_ctxt.
4602         Don't transition to m_non_heap for ADDR_EXPR(MEM_REF()).
4603         (malloc_state_machine::reset_when_passed_to_unknown_fn_p): New
4604         vfunc implementation.
4605         * sm-sensitive.cc (sensitive_state_machine::warn_for_any_exposure): Call
4606         get_diagnostic_tree and pass the result to warn_for_state.
4607         * sm-signal.cc: Move includes of "analyzer/call-string.h" and
4608         "analyzer/program-point.h" to before "analyzer/region-model.h",
4609         and also include "analyzer/store.h" before it.
4610         (signal_unsafe_call::describe_state_change): Use
4611         get_dest_function to get handler.
4612         (update_model_for_signal_handler): Pass manager to region_model
4613         ctor.
4614         (register_signal_handler::impl_transition): Update for changes to
4615         get_or_create_node and add_edge.
4616         * sm-taint.cc (taint_state_machine::on_stmt): Remove calls to
4617         get_readable_tree, replacing them when calling warn_for_state with
4618         calls to get_diagnostic_tree.
4619         * sm.cc (is_zero_assignment): Delete.
4620         (any_pointer_p): Move to within namespace ana.
4621         * sm.h (is_zero_assignment): Remove decl.
4622         (any_pointer_p): Move decl to within namespace ana.
4623         (state_machine::get_default_state): New vfunc.
4624         (state_machine::reset_when_passed_to_unknown_fn_p): New vfunc.
4625         (sm_context::get_readable_tree): Rename to...
4626         (sm_context::get_diagnostic_tree): ...this.
4627         (sm_context::is_zero_assignment): New vfunc.
4628         * store.cc: New file.
4629         * store.h: New file.
4630         * svalue.cc: New file.
4632 2020-05-22  Mark Wielaard  <mark@klomp.org>
4634         * sm-signal.cc(signal_unsafe_call::emit): Possibly add
4635         gcc_rich_location note for replacement.
4636         (signal_unsafe_call::get_replacement_fn): New private function.
4637         (get_async_signal_unsafe_fns): Add "exit".
4639 2020-04-28  David Malcolm  <dmalcolm@redhat.com>
4641         PR analyzer/94816
4642         * engine.cc (impl_region_model_context::on_unexpected_tree_code):
4643         Handle NULL tree.
4644         * region-model.cc (region_model::add_region_for_type): Handle
4645         NULL type.
4646         * region-model.h
4647         (test_region_model_context::on_unexpected_tree_code): Handle NULL
4648         tree.
4650 2020-04-28  David Malcolm  <dmalcolm@redhat.com>
4652         PR analyzer/94447
4653         PR analyzer/94639
4654         PR analyzer/94732
4655         PR analyzer/94754
4656         * analyzer.opt (Wanalyzer-use-of-uninitialized-value): Delete.
4657         * program-state.cc (selftest::test_program_state_dumping): Update
4658         expected dump result for removal of "uninit".
4659         * region-model.cc (poison_kind_to_str): Delete POISON_KIND_UNINIT
4660         case.
4661         (root_region::ensure_stack_region): Initialize stack with null
4662         svalue_id rather than with a typeless POISON_KIND_UNINIT value.
4663         (root_region::ensure_heap_region): Likewise for the heap.
4664         (region_model::dump_summary_of_rep_path_vars): Remove
4665         summarization of uninit values.
4666         (region_model::validate): Remove check that the stack has a
4667         POISON_KIND_UNINIT value.
4668         (poisoned_value_diagnostic::emit): Remove POISON_KIND_UNINIT
4669         case.
4670         (poisoned_value_diagnostic::describe_final_event): Likewise.
4671         (selftest::test_dump): Update expected dump result for removal of
4672         "uninit".
4673         (selftest::test_svalue_equality): Remove "uninit" and "freed".
4674         * region-model.h (enum poison_kind): Remove POISON_KIND_UNINIT.
4676 2020-04-01  David Malcolm  <dmalcolm@redhat.com>
4678         PR analyzer/94378
4679         * checker-path.cc: Include "bitmap.h".
4680         * constraint-manager.cc: Likewise.
4681         * diagnostic-manager.cc: Likewise.
4682         * engine.cc: Likewise.
4683         (exploded_node::detect_leaks): Pass null region_id to pop_frame.
4684         * program-point.cc: Include "bitmap.h".
4685         * program-state.cc: Likewise.
4686         * region-model.cc (id_set<region_id>::id_set): Convert to...
4687         (region_id_set::region_id_set): ...this.
4688         (svalue_id_set::svalue_id_set): New ctor.
4689         (region_model::copy_region): New function.
4690         (region_model::copy_struct_region): New function.
4691         (region_model::copy_union_region): New function.
4692         (region_model::copy_array_region): New function.
4693         (stack_region::pop_frame): Drop return value.  Add
4694         "result_dst_rid" param; if it is non-null, use copy_region to copy
4695         the result to it.  Rather than capture and pass a single "known
4696         used" return value to be used by purge_unused_values, instead
4697         gather and pass a set of known used return values.
4698         (root_region::pop_frame): Drop return value.  Add "result_dst_rid"
4699         param.
4700         (region_model::on_assignment): Use copy_region.
4701         (region_model::on_return): Likewise for the result.
4702         (region_model::on_longjmp): Pass null for pop_frame's
4703         result_dst_rid.
4704         (region_model::update_for_return_superedge): Pass the region for the
4705         return value of the call, if any, to pop_frame, rather than setting
4706         the lvalue for the lhs of the result.
4707         (region_model::pop_frame): Drop return value.  Add
4708         "result_dst_rid" param.
4709         (region_model::purge_unused_svalues): Convert third param from an
4710         svalue_id * to an svalue_id_set *, updating the initial populating
4711         of the "used" bitmap accordingly.  Don't remap it when done.
4712         (struct selftest::coord_test): New selftest fixture, extracted from...
4713         (selftest::test_dump_2): ...here.
4714         (selftest::test_compound_assignment): New selftest.
4715         (selftest::test_stack_frames): Pass null to new param of pop_frame.
4716         (selftest::analyzer_region_model_cc_tests): Call the new selftest.
4717         * region-model.h (class id_set): Delete template.
4718         (class region_id_set): Reimplement, using old id_set implementation.
4719         (class svalue_id_set): Likewise.  Convert from auto_sbitmap to
4720         auto_bitmap.
4721         (region::get_active_view): New accessor.
4722         (stack_region::pop_frame): Drop return value.  Add
4723         "result_dst_rid" param.
4724         (root_region::pop_frame): Likewise.
4725         (region_model::pop_frame): Likewise.
4726         (region_model::copy_region): New decl.
4727         (region_model::purge_unused_svalues): Convert third param from an
4728         svalue_id * to an svalue_id_set *.
4729         (region_model::copy_struct_region): New decl.
4730         (region_model::copy_union_region): New decl.
4731         (region_model::copy_array_region): New decl.
4733 2020-03-27  David Malcolm  <dmalcolm@redhat.com>
4735         * program-state.cc (selftest::test_program_state_dumping): Update
4736         expected dump to include symbolic_region's possibly_null field.
4737         * region-model.cc (symbolic_region::print_fields): New vfunc
4738         implementation.
4739         (region_model::add_constraint): Clear m_possibly_null from
4740         symbolic_regions now known to be non-NULL.
4741         (selftest::test_malloc_constraints): New selftest.
4742         (selftest::analyzer_region_model_cc_tests): Call it.
4743         * region-model.h (region::dyn_cast_symbolic_region): Add non-const
4744         overload.
4745         (symbolic_region::dyn_cast_symbolic_region): Implement it.
4746         (symbolic_region::print_fields): New vfunc override decl.
4748 2020-03-27  David Malcolm  <dmalcolm@redhat.com>
4750         * analyzer.h (class feasibility_problem): New forward decl.
4751         * diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
4752         Initialize new fields m_status, m_epath_length, and m_problem.
4753         (saved_diagnostic::~saved_diagnostic): Delete m_problem.
4754         (dedupe_candidate::dedupe_candidate): Convert "sd" param from a
4755         const ref to a mutable ptr.
4756         (dedupe_winners::add): Convert "sd" param from a const ref to a
4757         mutable ptr.  Record the length of the exploded_path.  Record the
4758         feasibility/infeasibility of sd into sd, capturing a
4759         feasibility_problem when feasible_p fails, and storing it in sd.
4760         (diagnostic_manager::emit_saved_diagnostics): Update for pass by
4761         ptr rather than by const ref.
4762         * diagnostic-manager.h (class saved_diagnostic): Add new enum
4763         status.  Add fields m_status, m_epath_length and m_problem.
4764         (saved_diagnostic::set_feasible): New member function.
4765         (saved_diagnostic::set_infeasible): New member function.
4766         (saved_diagnostic::get_feasibility_problem): New accessor.
4767         (saved_diagnostic::get_status): New accessor.
4768         (saved_diagnostic::set_epath_length): New member function.
4769         (saved_diagnostic::get_epath_length): New accessor.
4770         * engine.cc: Include "gimple-pretty-print.h".
4771         (exploded_path::feasible_p): Add OUT param and, if non-NULL, write
4772         a new feasibility_problem to it on failure.
4773         (viz_callgraph_node::dump_dot): Convert begin_tr calls to
4774         begin_trtd.  Convert end_tr calls to end_tdtr.
4775         (class exploded_graph_annotator): New subclass of dot_annotator.
4776         (impl_run_checkers): Add a second -fdump-analyzer-supergraph dump
4777         after the analysis runs, using exploded_graph_annotator. dumping
4778         to DUMP_BASE_NAME.supergraph-eg.dot.
4779         * exploded-graph.h (exploded_node::get_dot_fillcolor): Make
4780         public.
4781         (exploded_path::feasible_p): Add OUT param.
4782         (class feasibility_problem): New class.
4783         * state-purge.cc (state_purge_annotator::add_node_annotations):
4784         Return a bool, add a "within_table" param.
4785         (print_vec_of_names): Convert begin_tr calls to begin_trtd.
4786         Convert end_tr calls to end_tdtr.
4787         (state_purge_annotator::add_stmt_annotations): Add "within_row"
4788         param.
4789         * state-purge.h ((state_purge_annotator::add_node_annotations):
4790         Return a bool, add a "within_table" param.
4791         (state_purge_annotator::add_stmt_annotations): Add "within_row"
4792         param.
4793         * supergraph.cc (supernode::dump_dot): Call add_node_annotations
4794         twice: as before, passing false for "within_table", then again
4795         with true when within the TABLE element.  Convert some begin_tr
4796         calls to begin_trtd, and some end_tr calls to end_tdtr.
4797         Repeat each add_stmt_annotations call, distinguishing between
4798         calls that add TRs and those that add TDs to an existing TR.
4799         Add a call to add_after_node_annotations.
4800         * supergraph.h (dot_annotator::add_node_annotations): Add a
4801         "within_table" param.
4802         (dot_annotator::add_stmt_annotations): Add a "within_row" param.
4803         (dot_annotator::add_after_node_annotations): New vfunc.
4805 2020-03-27  David Malcolm  <dmalcolm@redhat.com>
4807         * diagnostic-manager.cc (dedupe_winners::add): Show the
4808         exploded_node index in the log messages.
4809         (diagnostic_manager::emit_saved_diagnostics): Log a summary of
4810         m_saved_diagnostics at entry.
4812 2020-03-27  David Malcolm  <dmalcolm@redhat.com>
4814         * supergraph.cc (superedge::dump): Add space before description;
4815         move newline to non-pretty_printer overload.
4817 2020-03-18  David Malcolm  <dmalcolm@redhat.com>
4819         * region-model.cc: Include "stor-layout.h".
4820         (region_model::dump_to_pp): Rather than calling
4821         dump_summary_of_map on each of the current frame and the globals,
4822         instead get a vec of representative path_vars for all regions,
4823         and then dump a summary of all of them.
4824         (region_model::dump_summary_of_map): Delete, rewriting into...
4825         (region_model::dump_summary_of_rep_path_vars): ...this new
4826         function, working on a vec of path_vars.
4827         (region_model::set_value): New overload.
4828         (region_model::get_representative_path_var): Rename
4829         "parent_region" local to "parent_reg" and consolidate with other
4830         local.  Guard test for grandparent being stack on parent_reg being
4831         non-NULL.  Move handling for parent being an array_region to
4832         within guard for parent_reg being non-NULL.
4833         (selftest::make_test_compound_type): New function.
4834         (selftest::test_dump_2): New selftest.
4835         (selftest::test_dump_3): New selftest.
4836         (selftest::test_stack_frames): Update expected output from
4837         simplified dump to show "a" and "b" from parent frame and "y" in
4838         child frame.
4839         (selftest::analyzer_region_model_cc_tests): Call test_dump_2 and
4840         test_dump_3.
4841         * region-model.h (region_model::set_value): New overload decl.
4842         (region_model::dump_summary_of_map): Delete.
4843         (region_model::dump_summary_of_rep_path_vars): New.
4845 2020-03-18  David Malcolm  <dmalcolm@redhat.com>
4847         * region-model.h (class noop_region_model_context): New subclass
4848         of region_model_context.
4849         (class tentative_region_model_context): Inherit from
4850         noop_region_model_context rather than from region_model_context;
4851         drop redundant vfunc implementations.
4852         (class test_region_model_context): Likewise.
4854 2020-03-18  David Malcolm  <dmalcolm@redhat.com>
4856         * engine.cc (exploded_node::exploded_node): Move implementation
4857         here from header; accept point_and_state by const reference rather
4858         than by value.
4859         * exploded-graph.h (exploded_node::exploded_node): Pass
4860         point_and_state by const reference rather than by value.  Move
4861         body to engine.cc.
4863 2020-03-18  Jakub Jelinek  <jakub@redhat.com>
4865         * sm-malloc.cc (malloc_state_machine::on_stmt): Fix up duplicated word
4866         issue in a comment.
4867         * region-model.cc (region_model::make_region_for_unexpected_tree_code,
4868         region_model::delete_region_and_descendents): Likewise.
4869         * engine.cc (class exploded_cluster): Likewise.
4870         * diagnostic-manager.cc (class path_builder): Likewise.
4872 2020-03-13  David Malcolm  <dmalcolm@redhat.com>
4874         PR analyzer/94099
4875         PR analyzer/94105
4876         * diagnostic-manager.cc (for_each_state_change): Bulletproof
4877         against errors in get_rvalue by passing a
4878         tentative_region_model_context and rejecting if there's an error.
4879         * region-model.cc (region_model::get_lvalue_1): When handling
4880         ARRAY_REF, handle results of error-handling.  Handle NOP_EXPR.
4882 2020-03-06  David Malcolm  <dmalcolm@redhat.com>
4884         * analyzer.h (class array_region): New forward decl.
4885         * program-state.cc (selftest::test_program_state_dumping_2): New.
4886         (selftest::analyzer_program_state_cc_tests): Call it.
4887         * region-model.cc (array_region::constant_from_key): New.
4888         (region_model::get_representative_tree): Handle region_svalue by
4889         generating an ADDR_EXPR.
4890         (region_model::get_representative_path_var): In view handling,
4891         remove erroneous TREE_TYPE when determining the type of the tree.
4892         Handle array regions and STRING_CST.
4893         (selftest::assert_dump_tree_eq): New.
4894         (ASSERT_DUMP_TREE_EQ): New macro.
4895         (selftest::test_get_representative_tree): New selftest.
4896         (selftest::analyzer_region_model_cc_tests): Call it.
4897         * region-model.h (region::dyn_cast_array_region): New vfunc.
4898         (array_region::dyn_cast_array_region): New vfunc implementation.
4899         (array_region::constant_from_key): New decl.
4901 2020-03-06  David Malcolm  <dmalcolm@redhat.com>
4903         * analyzer.h (dump_quoted_tree): New decl.
4904         * engine.cc (exploded_node::dump_dot): Pass region model to
4905         sm_state_map::print.
4906         * program-state.cc: Include diagnostic-core.h.
4907         (sm_state_map::print): Add "model" param and use it to print
4908         representative trees.  Only print origin information if non-null.
4909         (sm_state_map::dump): Pass NULL for model to print call.
4910         (program_state::print): Pass region model to sm_state_map::print.
4911         (program_state::dump_to_pp): Use spaces rather than newlines when
4912         summarizing.  Pass region_model to sm_state_map::print.
4913         (ana::selftest::assert_dump_eq): New function.
4914         (ASSERT_DUMP_EQ): New macro.
4915         (ana::selftest::test_program_state_dumping): New function.
4916         (ana::selftest::analyzer_program_state_cc_tests): Call it.
4917         * program-state.h (program_state::print): Add model param.
4918         * region-model.cc (dump_quoted_tree): New function.
4919         (map_region::print_fields): Use dump_quoted_tree rather than
4920         %qE to avoid lang-dependent output.
4921         (map_region::dump_child_label): Likewise.
4922         (region_model::dump_summary_of_map): For SK_REGION, when
4923         get_representative_path_var fails, print the region id rather than
4924         erroneously printing NULL.
4925         * sm.cc (state_machine::get_state_by_name): New function.
4926         * sm.h (state_machine::get_state_by_name): New decl.
4928 2020-03-04  David Malcolm  <dmalcolm@redhat.com>
4930         * region-model.cc (region::validate): Convert model param from ptr
4931         to reference.  Update comment to reflect that it's now a vfunc.
4932         (map_region::validate): New vfunc implementation.
4933         (array_region::validate): New vfunc implementation.
4934         (stack_region::validate): New vfunc implementation.
4935         (root_region::validate): New vfunc implementation.
4936         (region_model::validate): Pass a reference rather than a pointer
4937         to the region::validate vfunc.
4938         * region-model.h (region::validate): Make virtual.  Convert model
4939         param from ptr to reference.
4940         (map_region::validate): New vfunc decl.
4941         (array_region::validate): New vfunc decl.
4942         (stack_region::validate): New vfunc decl.
4943         (root_region::validate): New vfunc decl.
4945 2020-03-04  David Malcolm  <dmalcolm@redhat.com>
4947         PR analyzer/93993
4948         * region-model.cc (region_model::on_call_pre): Handle
4949         BUILT_IN_EXPECT and its variants.
4950         (region_model::add_any_constraints_from_ssa_def_stmt): Split out
4951         gassign handling into add_any_constraints_from_gassign; add gcall
4952         handling.
4953         (region_model::add_any_constraints_from_gassign): New function,
4954         based on the above.  Add handling for NOP_EXPR.
4955         (region_model::add_any_constraints_from_gcall): New function.
4956         (region_model::get_representative_path_var): Handle views.
4957         * region-model.h
4958         (region_model::add_any_constraints_from_ssa_def_stmt): New decl.
4959         (region_model::add_any_constraints_from_gassign): New decl.
4961 2020-03-04  David Malcolm  <dmalcolm@redhat.com>
4963         PR analyzer/93993
4964         * checker-path.h (state_change_event::get_lvalue): Add ctxt param
4965         and pass it to region_model::get_value call.
4966         * diagnostic-manager.cc (get_any_origin): Pass a
4967         tentative_region_model_context to the calls to get_lvalue and reject
4968         the comparison if errors occur.
4969         (can_be_expr_of_interest_p): New function.
4970         (diagnostic_manager::prune_for_sm_diagnostic): Replace checks for
4971         CONSTANT_CLASS_P with calls to update_for_unsuitable_sm_exprs.
4972         Pass a tentative_region_model_context to the calls to
4973         state_change_event::get_lvalue and reject the comparison if errors
4974         occur.
4975         (diagnostic_manager::update_for_unsuitable_sm_exprs): New.
4976         * diagnostic-manager.h
4977         (diagnostic_manager::update_for_unsuitable_sm_exprs): New decl.
4978         * region-model.h (class tentative_region_model_context): New class.
4980 2020-03-04  David Malcolm  <dmalcolm@redhat.com>
4982         * engine.cc (worklist::worklist): Remove unused field m_eg.
4983         (class viz_callgraph_edge): Remove unused field m_call_sedge.
4984         (class viz_callgraph): Remove unused field m_sg.
4985         * exploded-graph.h (worklist::::m_eg): Remove unused field.
4987 2020-03-02  David Malcolm  <dmalcolm@redhat.com>
4989         * analyzer.opt (fanalyzer-show-duplicate-count): New option.
4990         * diagnostic-manager.cc
4991         (diagnostic_manager::emit_saved_diagnostic): Use the above to
4992         guard the printing of the duplicate count.
4994 2020-03-02  David Malcolm  <dmalcolm@redhat.com>
4996         PR analyzer/93959
4997         * analyzer.cc (is_std_function_p): New function.
4998         (is_std_named_call_p): New functions.
4999         * analyzer.h (is_std_named_call_p): New decl.
5000         * sm-malloc.cc (malloc_state_machine::on_stmt): Check for "std::"
5001         variants when checking for malloc, calloc and free.
5003 2020-02-26  David Malcolm  <dmalcolm@redhat.com>
5005         PR analyzer/93950
5006         * diagnostic-manager.cc
5007         (diagnostic_manager::prune_for_sm_diagnostic): Assert that var is
5008         either NULL or not a constant.  When updating var, bulletproof
5009         against constant values.
5011 2020-02-26  David Malcolm  <dmalcolm@redhat.com>
5013         PR analyzer/93947
5014         * region-model.cc (region_model::get_fndecl_for_call): Gracefully
5015         fail for fn_decls that don't have a cgraph_node.
5017 2020-02-26  David Malcolm  <dmalcolm@redhat.com>
5019         * bar-chart.cc: New file.
5020         * bar-chart.h: New file.
5021         * engine.cc: Include "analyzer/bar-chart.h".
5022         (stats::log): Only log the m_num_nodes kinds that are non-zero.
5023         (stats::dump): Likewise when dumping.
5024         (stats::get_total_enodes): New.
5025         (exploded_graph::get_or_create_node): Increment the per-point-data
5026         m_excess_enodes when hitting the per-program-point limit on
5027         enodes.
5028         (exploded_graph::print_bar_charts): New.
5029         (exploded_graph::log_stats): Log the number of unprocessed enodes
5030         in the worklist.  Call print_bar_charts.
5031         (exploded_graph::dump_stats): Print the number of unprocessed
5032         enodes in the worklist.
5033         * exploded-graph.h (stats::get_total_enodes): New decl.
5034         (struct per_program_point_data): Add field m_excess_enodes.
5035         (exploded_graph::print_bar_charts): New decl.
5036         * supergraph.cc (superedge::dump): New.
5037         (superedge::dump): New.
5038         * supergraph.h (supernode::get_function): New.
5039         (superedge::dump): New decl.
5040         (superedge::dump): New decl.
5042 2020-02-24  David Malcolm  <dmalcolm@redhat.com>
5044         * engine.cc (exploded_graph::get_or_create_node): Dump the
5045         program_state to the pp, rather than to stderr.
5047 2020-02-24  David Malcolm  <dmalcolm@redhat.com>
5049         PR analyzer/93032
5050         * sm.cc (make_checkers): Require the "taint" checker to be
5051         explicitly enabled.
5053 2020-02-24  David Malcolm  <dmalcolm@redhat.com>
5055         PR analyzer/93899
5056         * engine.cc
5057         (impl_region_model_context::impl_region_model_context): Add logger
5058         param.
5059         * engine.cc (exploded_graph::add_function_entry): Create an
5060         impl_region_model_context and pass it to the push_frame call.
5061         Bail if the resulting state is invalid.
5062         (exploded_graph::build_initial_worklist): Likewise.
5063         (exploded_graph::build_initial_worklist): Handle the case where
5064         add_function_entry fails.
5065         * exploded-graph.h
5066         (impl_region_model_context::impl_region_model_context): Add logger
5067         param.
5068         * region-model.cc (map_region::get_or_create): Add ctxt param and
5069         pass it to add_region_for_type.
5070         (map_region::can_merge_p): Pass NULL as a ctxt to call to
5071         get_or_create.
5072         (array_region::get_element): Pass ctxt to call to get_or_create.
5073         (array_region::get_or_create): Add ctxt param and pass it to
5074         add_region_for_type.
5075         (root_region::push_frame): Pass ctxt to get_or_create calls.
5076         (region_model::get_lvalue_1): Likewise.
5077         (region_model::make_region_for_unexpected_tree_code): Assert that
5078         ctxt is non-NULL.
5079         (region_model::get_rvalue_1): Pass ctxt to get_svalue_for_fndecl
5080         and get_svalue_for_label calls.
5081         (region_model::get_svalue_for_fndecl): Add ctxt param and pass it
5082         to get_region_for_fndecl.
5083         (region_model::get_region_for_fndecl): Add ctxt param and pass it
5084         to get_or_create.
5085         (region_model::get_svalue_for_label): Add ctxt param and pass it
5086         to get_region_for_label.
5087         (region_model::get_region_for_label): Add ctxt param and pass it
5088         to get_region_for_fndecl and get_or_create.
5089         (region_model::get_field_region): Add ctxt param and pass it to
5090         get_or_create_view and get_or_create.
5091         (make_region_for_type): Replace gcc_unreachable with return NULL.
5092         (region_model::add_region_for_type): Add ctxt param.  Handle a
5093         return of NULL from make_region_for_type by calling
5094         make_region_for_unexpected_tree_code.
5095         (region_model::get_or_create_mem_ref): Pass ctxt to calls to
5096         get_or_create_view.
5097         (region_model::get_or_create_view): Add ctxt param and pass it to
5098         add_region_for_type.
5099         (selftest::test_state_merging): Pass ctxt to get_or_create_view.
5100         * region-model.h (region_model::get_or_create): Add ctxt param.
5101         (region_model::add_region_for_type): Likewise.
5102         (region_model::get_svalue_for_fndecl): Likewise.
5103         (region_model::get_svalue_for_label): Likewise.
5104         (region_model::get_region_for_fndecl): Likewise.
5105         (region_model::get_region_for_label): Likewise.
5106         (region_model::get_field_region): Likewise.
5107         (region_model::get_or_create_view): Likewise.
5109 2020-02-24  David Malcolm  <dmalcolm@redhat.com>
5111         * checker-path.cc (superedge_event::should_filter_p): Update
5112         filter for empty descriptions to cover verbosity level 3 as well
5113         as 2.
5114         * diagnostic-manager.cc: Include "analyzer/reachability.h".
5115         (class path_builder): New class.
5116         (diagnostic_manager::emit_saved_diagnostic): Create a path_builder
5117         and pass it to build_emission_path, rather passing eg; similarly
5118         for add_events_for_eedge and ext_state.
5119         (diagnostic_manager::build_emission_path): Replace "eg" param
5120         with a path_builder, pass it to add_events_for_eedge.
5121         (diagnostic_manager::add_events_for_eedge): Replace ext_state
5122         param with path_builder; pass it to add_events_for_superedge.
5123         (diagnostic_manager::significant_edge_p): New.
5124         (diagnostic_manager::add_events_for_superedge): Add path_builder
5125         param.  Reject insignificant edges at verbosity levels below 3.
5126         (diagnostic_manager::prune_for_sm_diagnostic): Update highest
5127         verbosity level to 4.
5128         * diagnostic-manager.h (class path_builder): New forward decl.
5129         (diagnostic_manager::build_emission_path): Replace "eg" param
5130         with a path_builder.
5131         (diagnostic_manager::add_events_for_eedge): Replace ext_state
5132         param with path_builder.
5133         (diagnostic_manager::significant_edge_p): New.
5134         (diagnostic_manager::add_events_for_superedge): Add path_builder
5135         param.
5136         * reachability.h: New file.
5138 2020-02-18  David Malcolm  <dmalcolm@redhat.com>
5140         PR analyzer/93692
5141         * analyzer.opt (fdump-analyzer-callgraph): Rewrite description.
5143 2020-02-18  David Malcolm  <dmalcolm@redhat.com>
5145         PR analyzer/93777
5146         * region-model.cc (region_model::maybe_cast_1): Replace assertion
5147         that build_cast returns non-NULL with a conditional, falling
5148         through to the logic which returns a new unknown value of the
5149         desired type if it fails.
5151 2020-02-18  David Malcolm  <dmalcolm@redhat.com>
5153         PR analyzer/93778
5154         * engine.cc (impl_region_model_context::on_unknown_tree_code):
5155         Rename to...
5156         (impl_region_model_context::on_unexpected_tree_code): ...this and
5157         convert first argument from path_var to tree.
5158         (exploded_node::on_stmt): Pass ctxt to purge_for_unknown_fncall.
5159         * exploded-graph.h (region_model_context::on_unknown_tree_code):
5160         Rename to...
5161         (region_model_context::on_unexpected_tree_code): ...this and
5162         convert first argument from path_var to tree.
5163         * program-state.cc (sm_state_map::purge_for_unknown_fncall): Add
5164         ctxt param and pass on to calls to get_rvalue.
5165         * program-state.h (sm_state_map::purge_for_unknown_fncall): Add
5166         ctxt param.
5167         * region-model.cc (region_model::handle_unrecognized_call): Pass
5168         ctxt on to call to get_rvalue.
5169         (region_model::get_lvalue_1): Move body of default case to
5170         region_model::make_region_for_unexpected_tree_code and call it.
5171         Within COMPONENT_REF case, reject attempts to handle types other
5172         than RECORD_TYPE and UNION_TYPE.
5173         (region_model::make_region_for_unexpected_tree_code): New
5174         function, based on default case of region_model::get_lvalue_1.
5175         * region-model.h
5176         (region_model::make_region_for_unexpected_tree_code): New decl.
5177         (region_model::on_unknown_tree_code): Rename to...
5178         (region_model::on_unexpected_tree_code): ...this and convert first
5179         argument from path_var to tree.
5180         (class test_region_model_context): Update vfunc implementation for
5181         above change.
5183 2020-02-18  David Malcolm  <dmalcolm@redhat.com>
5185         PR analyzer/93774
5186         * region-model.cc
5187         (region_model::convert_byte_offset_to_array_index): Use
5188         int_size_in_bytes before calling size_in_bytes, to gracefully fail
5189         on incomplete types.
5191 2020-02-17  David Malcolm  <dmalcolm@redhat.com>
5193         PR analyzer/93775
5194         * region-model.cc (region_model::get_fndecl_for_call): Handle the
5195         case where the code_region's get_tree_for_child_region returns
5196         NULL.
5198 2020-02-17  David Malcolm  <dmalcolm@redhat.com>
5200         PR analyzer/93388
5201         * engine.cc (impl_region_model_context::on_unknown_tree_code):
5202         New.
5203         (exploded_graph::get_or_create_node): Reject invalid states.
5204         * exploded-graph.h
5205         (impl_region_model_context::on_unknown_tree_code): New decl.
5206         (point_and_state::point_and_state): Assert that the state is
5207         valid.
5208         * program-state.cc (program_state::program_state): Initialize
5209         m_valid to true.
5210         (program_state::operator=): Copy m_valid.
5211         (program_state::program_state): Likewise for move constructor.
5212         (program_state::print): Print m_valid.
5213         (program_state::dump_to_pp): Likewise.
5214         * program-state.h (program_state::m_valid): New field.
5215         * region-model.cc (region_model::get_lvalue_1): Implement the
5216         default case by returning a new symbolic region and calling
5217         the context's on_unknown_tree_code, rather than issuing an
5218         internal_error.  Implement VIEW_CONVERT_EXPR.
5219         * region-model.h (region_model_context::on_unknown_tree_code): New
5220         vfunc.
5221         (test_region_model_context::on_unknown_tree_code): New.
5223 2020-02-17  David Malcolm  <dmalcolm@redhat.com>
5225         * sm-malloc.cc (malloc_diagnostic::describe_state_change): For
5226         transition to the "null" state, only say "assuming" when
5227         transitioning from the "unchecked" state.
5229 2020-02-17  David Malcolm  <dmalcolm@redhat.com>
5231         * diagnostic-manager.h (diagnostic_manager::get_saved_diagnostic):
5232         Add const overload.
5233         * engine.cc (exploded_node::dump_dot): Dump saved_diagnostics.
5234         * exploded-graph.h (exploded_graph::get_diagnostic_manager): Add
5235         const overload.
5237 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5239         PR analyzer/93288
5240         * analysis-plan.cc (analysis_plan::use_summary_p): Look through
5241         the ultimate_alias_target when getting the called function.
5242         * engine.cc (exploded_node::on_stmt): Rename second "ctxt" to
5243         "sm_ctxt".  Use the region_model's get_fndecl_for_call rather than
5244         gimple_call_fndecl.
5245         * region-model.cc (region_model::get_fndecl_for_call): Use
5246         ultimate_alias_target on fndecl.
5247         * supergraph.cc (get_ultimate_function_for_cgraph_edge): New
5248         function.
5249         (supergraph_call_edge): Use it when rejecting edges without
5250         functions.
5251         (supergraph::supergraph): Use it to get the function for the
5252         cgraph_edge when building interprocedural superedges.
5253         (callgraph_superedge::get_callee_function):  Use it.
5254         * supergraph.h (supergraph::get_num_snodes): Make param const.
5255         (supergraph::function_to_num_snodes_t): Make first type param
5256         const.
5258 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5260         PR analyzer/93374
5261         * engine.cc (exploded_edge::exploded_edge): Add ext_state param
5262         and pass it to change.validate.
5263         (exploded_graph::get_or_create_node): Move purging of change
5264         svalues to also cover the case of reusing an existing enode.
5265         (exploded_graph::add_edge): Pass m_ext_state to exploded_edge's
5266         ctor.
5267         * exploded-graph.h (exploded_edge::exploded_edge): Add ext_state
5268         param.
5269         * program-state.cc (state_change::sm_change::validate): Likewise.
5270         Assert that m_sm_idx is sane.  Use ext_state to validate
5271         m_old_state and m_new_state.
5272         (state_change::validate): Add ext_state param and pass it to
5273         the sm_change validate calls.
5274         * program-state.h (state_change::sm_change::validate): Add
5275         ext_state param.
5276         (state_change::validate): Likewise.
5278 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5280         PR analyzer/93669
5281         * engine.cc (exploded_graph::dump_exploded_nodes): Handle missing
5282         case of STATUS_WORKLIST in implementation of
5283         "__analyzer_dump_exploded_nodes".
5285 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5287         PR analyzer/93649
5288         * constraint-manager.cc (constraint_manager::add_constraint): When
5289         merging equivalence classes and updating m_constant, also update
5290         m_cst_sid.
5291         (constraint_manager::validate): If m_constant is non-NULL assert
5292         that m_cst_sid is non-null and is valid.
5294 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5296         PR analyzer/93657
5297         * analyzer.opt (fdump-analyzer): Reword description.
5298         (fdump-analyzer-stderr): Likewise.
5300 2020-02-11  David Malcolm  <dmalcolm@redhat.com>
5302         * region-model.cc (print_quoted_type): New function.
5303         (svalue::print): Use it to replace %qT.
5304         (region::dump_to_pp): Likewise.
5305         (region::dump_child_label): Likewise.
5306         (region::print_fields): Likewise.
5308 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
5310         PR analyzer/93659
5311         * analyzer.opt (-param=analyzer-max-recursion-depth=): Fix "tha"
5312         -> "that" typo.
5313         (Wanalyzer-use-of-uninitialized-value): Fix "initialized" ->
5314         "uninitialized" typo.
5316 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
5318         PR analyzer/93350
5319         * region-model.cc (region_model::get_lvalue_1):
5320         Handle BIT_FIELD_REF.
5321         (make_region_for_type): Handle VECTOR_TYPE.
5323 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
5325         PR analyzer/93647
5326         * diagnostic-manager.cc
5327         (diagnostic_manager::prune_for_sm_diagnostic): Bulletproof against
5328         VAR being constant.
5329         * region-model.cc (region_model::get_lvalue_1): Provide a better
5330         error message when encountering an unhandled tree code.
5332 2020-02-10  David Malcolm  <dmalcolm@redhat.com>
5334         PR analyzer/93405
5335         * region-model.cc (region_model::get_lvalue_1): Implement
5336         CONST_DECL.
5338 2020-02-06  David Malcolm  <dmalcolm@redhat.com>
5340         * region-model.cc (region_model::maybe_cast_1): Attempt to provide
5341         a region_svalue if either type is a pointer, rather than if both
5342         types are pointers.
5344 2020-02-05  David Malcolm  <dmalcolm@redhat.com>
5346         * engine.cc (exploded_node::dump_dot): Show merger enodes.
5347         (worklist::add_node): Assert that the node's m_status is
5348         STATUS_WORKLIST.
5349         (exploded_graph::process_worklist): Likewise for nodes from the
5350         worklist.  Set status of merged nodes to STATUS_MERGER.
5351         (exploded_graph::process_node): Set status of node to
5352         STATUS_PROCESSED.
5353         (exploded_graph::dump_exploded_nodes): Rework handling of
5354         "__analyzer_dump_exploded_nodes", splitting enodes by status into
5355         "processed" and "merger", showing the count of just the processed
5356         enodes at the call, rather than the count of all enodes.
5357         * exploded-graph.h (exploded_node::status): New enum.
5358         (exploded_node::exploded_node): Initialize m_status to
5359         STATUS_WORKLIST.
5360         (exploded_node::get_status): New getter.
5361         (exploded_node::set_status): New setter.
5363 2020-02-04  David Malcolm  <dmalcolm@redhat.com>
5365         PR analyzer/93543
5366         * engine.cc (pod_hash_traits<function_call_string>::mark_empty):
5367         Eliminate reinterpret_cast.
5368         (pod_hash_traits<function_call_string>::is_empty): Likewise.
5370 2020-02-03  David Malcolm  <dmalcolm@redhat.com>
5372         * constraint-manager.cc (range::constrained_to_single_element):
5373         Replace fold_build2 with fold_binary.  Remove unnecessary newline.
5374         (constraint_manager::get_or_add_equiv_class): Replace fold_build2
5375         with fold_binary in two places, and remove out-of-date comment.
5376         (constraint_manager::eval_condition): Replace fold_build2 with
5377         fold_binary.
5378         * region-model.cc (constant_svalue::eval_condition): Likewise.
5379         (region_model::on_assignment): Likewise.
5381 2020-02-03  David Malcolm  <dmalcolm@redhat.com>
5383         PR analyzer/93544
5384         * diagnostic-manager.cc
5385         (diagnostic_manager::prune_for_sm_diagnostic): Bulletproof
5386         against bad choices due to bad paths.
5387         * engine.cc (impl_region_model_context::on_phi): New.
5388         * exploded-graph.h (impl_region_model_context::on_phi): New decl.
5389         * region-model.cc (region_model::on_longjmp): Likewise.
5390         (region_model::handle_phi): Add phi param.  Call the ctxt's on_phi
5391         vfunc.
5392         (region_model::update_for_phis): Pass phi to handle_phi.
5393         * region-model.h (region_model::handle_phi): Add phi param.
5394         (region_model_context::on_phi): New vfunc.
5395         (test_region_model_context::on_phi): New.
5396         * sm-malloc.cc (malloc_state_machine::on_phi): New.
5397         (malloc_state_machine::on_zero_assignment): New.
5398         * sm.h (state_machine::on_phi): New vfunc.
5400 2020-02-03  David Malcolm  <dmalcolm@redhat.com>
5402         * engine.cc (supernode_cluster::dump_dot): Show BB index as
5403         well as SN index.
5404         * supergraph.cc (supernode::dump_dot): Likewise.
5406 2020-02-03  David Malcolm  <dmalcolm@redhat.com>
5408         PR analyzer/93546
5409         * region-model.cc (region_model::on_call_pre): Update for new
5410         param of symbolic_region ctor.
5411         (region_model::deref_rvalue): Likewise.
5412         (region_model::add_new_malloc_region): Likewise.
5413         (make_region_for_type): Likewise, preserving type.
5414         * region-model.h (symbolic_region::symbolic_region): Add "type"
5415         param and pass it to base class ctor.
5417 2020-02-03  David Malcolm  <dmalcolm@redhat.com>
5419         PR analyzer/93547
5420         * constraint-manager.cc
5421         (constraint_manager::get_or_add_equiv_class): Ensure types are
5422         compatible before comparing constants.
5424 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5426         PR analyzer/93457
5427         * region-model.cc (make_region_for_type): Use VOID_TYPE_P rather
5428         than checking against void_type_node.
5430 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5432         PR analyzer/93373
5433         * region-model.cc (ASSERT_COMPAT_TYPES): Convert to...
5434         (assert_compat_types): ...this, and bail when either type is NULL,
5435         or when VOID_TYPE_P (dst_type).
5436         (region_model::get_lvalue): Update for above conversion.
5437         (region_model::get_rvalue): Likewise.
5439 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5441         PR analyzer/93379
5442         * region-model.cc (region_model::update_for_return_superedge):
5443         Move check for null result so that it also guards setting the
5444         lhs.
5446 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5448         PR analyzer/93438
5449         * region-model.cc (stack_region::can_merge_p): Split into a two
5450         pass approach, creating all stack regions first, then populating
5451         them.
5452         (selftest::test_state_merging): Add test coverage for (a) the case
5453         of self-merging a model in which a local in an older stack frame
5454         points to a local in a more recent stack frame (which previously
5455         would ICE), and (b) the case of self-merging a model in which a
5456         local points to a global (which previously worked OK).
5458 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5460         * analyzer.cc (is_named_call_p): Replace tests for fndecl being
5461         extern at file scope and having a non-NULL DECL_NAME with a call
5462         to maybe_special_function_p.
5463         * function-set.cc (function_set::contains_decl_p): Add call to
5464         maybe_special_function_p.
5466 2020-01-31  David Malcolm  <dmalcolm@redhat.com>
5468         PR analyzer/93450
5469         * constraint-manager.cc
5470         (constraint_manager::get_or_add_equiv_class): Only compare constants
5471         if their types are compatible.
5472         * region-model.cc (constant_svalue::eval_condition): Replace check
5473         for identical types with call to types_compatible_p.
5475 2020-01-30  David Malcolm  <dmalcolm@redhat.com>
5477         * program-state.cc (extrinsic_state::dump_to_pp): New.
5478         (extrinsic_state::dump_to_file): New.
5479         (extrinsic_state::dump): New.
5480         * program-state.h (extrinsic_state::dump_to_pp): New decl.
5481         (extrinsic_state::dump_to_file): New decl.
5482         (extrinsic_state::dump): New decl.
5483         * sm.cc: Include "pretty-print.h".
5484         (state_machine::dump_to_pp): New.
5485         * sm.h (state_machine::dump_to_pp): New decl.
5487 2020-01-30  David Malcolm  <dmalcolm@redhat.com>
5489         * diagnostic-manager.cc (for_each_state_change): Use
5490         extrinsic_state::get_num_checkers rather than accessing m_checkers
5491         directly.
5492         * program-state.cc (program_state::program_state): Likewise.
5493         * program-state.h (extrinsic_state::m_checkers): Make private.
5495 2020-01-30  David Malcolm  <dmalcolm@redhat.com>
5497         PR analyzer/93356
5498         * region-model.cc (region_model::eval_condition): In both
5499         overloads, bail out immediately on floating-point types.
5500         (region_model::eval_condition_without_cm): Likewise.
5501         (region_model::add_constraint): Likewise.
5503 2020-01-30  David Malcolm  <dmalcolm@redhat.com>
5505         PR analyzer/93450
5506         * program-state.cc (sm_state_map::set_state): For the overload
5507         taking an svalue_id, bail out if the set_state on the ec does
5508         nothing.  Convert the latter's return type from void to bool,
5509         returning true if anything changed.
5510         (sm_state_map::impl_set_state): Convert the return type from void
5511         to bool, returning true if the state changed.
5512         * program-state.h (sm_state_map::set_state): Convert return type
5513         from void to bool.
5514         (sm_state_map::impl_set_state): Likewise.
5515         * region-model.cc (constant_svalue::eval_condition): Only call
5516         fold_build2 if the types are the same.
5518 2020-01-29  Jakub Jelinek  <jakub@redhat.com>
5520         * analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Remove.
5521         * constraint-manager.cc: Include diagnostic-core.h before graphviz.h.
5522         (range::dump, equiv_class::print): Don't use PUSH_IGNORE_WFORMAT or
5523         POP_IGNORE_WFORMAT.
5524         * state-purge.cc: Include diagnostic-core.h before
5525         gimple-pretty-print.h.
5526         (state_purge_annotator::add_node_annotations, print_vec_of_names):
5527         Don't use PUSH_IGNORE_WFORMAT or POP_IGNORE_WFORMAT.
5528         * region-model.cc: Move diagnostic-core.h include before graphviz.h.
5529         (path_var::dump, svalue::print, constant_svalue::print_details,
5530         region::dump_to_pp, region::dump_child_label, region::print_fields,
5531         map_region::print_fields, map_region::dump_dot_to_pp,
5532         map_region::dump_child_label, array_region::print_fields,
5533         array_region::dump_dot_to_pp): Don't use PUSH_IGNORE_WFORMAT or
5534         POP_IGNORE_WFORMAT.
5536 2020-01-28  David Malcolm  <dmalcolm@redhat.com>
5538         PR analyzer/93316
5539         * engine.cc (rewind_info_t::update_model): Get the longjmp call
5540         stmt via get_longjmp_call () rather than assuming it is the last
5541         stmt in the longjmp's supernode.
5542         (rewind_info_t::add_events_to_path): Get the location_t for the
5543         rewind_from_longjmp_event via get_longjmp_call () rather than from
5544         the supernode's get_end_location ().
5546 2020-01-28  David Malcolm  <dmalcolm@redhat.com>
5548         * region-model.cc (poisoned_value_diagnostic::emit): Update for
5549         renaming of warning_at overload to warning_meta.
5550         * sm-file.cc (file_leak::emit): Likewise.
5551         * sm-malloc.cc (double_free::emit): Likewise.
5552         (possible_null_deref::emit): Likewise.
5553         (possible_null_arg::emit): Likewise.
5554         (null_deref::emit): Likewise.
5555         (null_arg::emit): Likewise.
5556         (use_after_free::emit): Likewise.
5557         (malloc_leak::emit): Likewise.
5558         (free_of_non_heap::emit): Likewise.
5559         * sm-sensitive.cc (exposure_through_output_file::emit): Likewise.
5560         * sm-signal.cc (signal_unsafe_call::emit): Likewise.
5561         * sm-taint.cc (tainted_array_index::emit): Likewise.
5563 2020-01-27  David Malcolm  <dmalcolm@redhat.com>
5565         PR analyzer/93451
5566         * region-model.cc (tree_cmp): For the REAL_CST case, impose an
5567         arbitrary order on NaNs relative to other NaNs and to non-NaNs;
5568         const-correctness tweak.
5569         (ana::selftests::build_real_cst_from_string): New function.
5570         (ana::selftests::append_interesting_constants): New function.
5571         (ana::selftests::test_tree_cmp_on_constants): New test.
5572         (ana::selftests::test_canonicalization_4): New test.
5573         (ana::selftests::analyzer_region_model_cc_tests): Call the new
5574         tests.
5576 2020-01-27  David Malcolm  <dmalcolm@redhat.com>
5578         PR analyzer/93349
5579         * engine.cc (run_checkers): Save and restore input_location.
5581 2020-01-27  David Malcolm  <dmalcolm@redhat.com>
5583         * call-string.cc (call_string::cmp_1): Delete, moving body to...
5584         (call_string::cmp): ...here.
5585         * call-string.h (call_string::cmp_1): Delete decl.
5586         * engine.cc (worklist::key_t::cmp_1): Delete, moving body to...
5587         (worklist::key_t::cmp): ...here.  Implement hash comparisons
5588         via comparison rather than subtraction to avoid overflow issues.
5589         * exploded-graph.h (worklist::key_t::cmp_1): Delete decl.
5590         * region-model.cc (tree_cmp): Eliminate buggy checking for
5591         symmetry.
5593 2020-01-27  David Malcolm  <dmalcolm@redhat.com>
5595         * analyzer.cc  (is_named_call_p): Check that fndecl is "extern"
5596         and at file scope.  Potentially disregard prefix _ or __ in
5597         fndecl's name.  Bail if the identifier is NULL.
5598         (is_setjmp_call_p): Expect a gcall rather than plain gimple.
5599         Remove special-case check for leading prefix, and also check for
5600         sigsetjmp.
5601         (is_longjmp_call_p): Also check for siglongjmp.
5602         (get_user_facing_name): New function.
5603         * analyzer.h (is_setjmp_call_p): Expect a gcall rather than plain
5604         gimple.
5605         (get_user_facing_name): New decl.
5606         * checker-path.cc (setjmp_event::get_desc): Use
5607         get_user_facing_name to avoid hardcoding the function name.
5608         (rewind_event::rewind_event): Add rewind_info param, using it to
5609         initialize new m_rewind_info field, and strengthen the assertion.
5610         (rewind_from_longjmp_event::get_desc): Use get_user_facing_name to
5611         avoid hardcoding the function name.
5612         (rewind_to_setjmp_event::get_desc): Likewise.
5613         * checker-path.h (setjmp_event::setjmp_event): Add setjmp_call
5614         param and use it to initialize...
5615         (setjmp_event::m_setjmp_call): New field.
5616         (rewind_event::rewind_event): Add rewind_info param.
5617         (rewind_event::m_rewind_info): New protected field.
5618         (rewind_from_longjmp_event::rewind_from_longjmp_event): Add
5619         rewind_info param.
5620         (class rewind_to_setjmp_event): Move rewind_info field to parent
5621         class.
5622         * diagnostic-manager.cc (diagnostic_manager::add_events_for_eedge):
5623         Update setjmp-handling for is_setjmp_call_p requiring a gcall;
5624         pass the call to the new setjmp_event.
5625         * engine.cc (exploded_node::on_stmt): Update for is_setjmp_call_p
5626         requiring a gcall.
5627         (stale_jmp_buf::emit): Use get_user_facing_name to avoid
5628         hardcoding the function names.
5629         (exploded_node::on_longjmp): Pass the longjmp_call when
5630         constructing rewind_info.
5631         (rewind_info_t::add_events_to_path): Pass the rewind_info_t to the
5632         rewind_from_longjmp_event's ctor.
5633         * exploded-graph.h (rewind_info_t::rewind_info_t): Add
5634         longjmp_call param.
5635         (rewind_info_t::get_longjmp_call): New.
5636         (rewind_info_t::m_longjmp_call): New.
5637         * region-model.cc (region_model::on_setjmp): Update comment to
5638         indicate this is also for sigsetjmp.
5639         * region-model.h (struct setjmp_record): Likewise.
5640         (class setjmp_svalue): Likewise.
5642 2020-01-27  David Malcolm  <dmalcolm@redhat.com>
5644         PR analyzer/93276
5645         * analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Guard these
5646         macros with GCC_VERSION >= 4006, making them no-op otherwise.
5647         * engine.cc (exploded_edge::exploded_edge): Specify template for
5648         base class initializer.
5649         (exploded_graph::add_edge): Specify template when chaining up to
5650         base class add_edge implementation.
5651         (viz_callgraph_node::dump_dot): Drop redundant "typename".
5652         (viz_callgraph_edge::viz_callgraph_edge): Specify template for
5653         base class initializer.
5654         * program-state.cc (sm_state_map::clone_with_remapping): Drop
5655         redundant "typename".
5656         (sm_state_map::print): Likewise.
5657         (sm_state_map::hash): Likewise.
5658         (sm_state_map::operator==): Likewise.
5659         (sm_state_map::remap_svalue_ids): Likewise.
5660         (sm_state_map::on_svalue_purge): Likewise.
5661         (sm_state_map::validate): Likewise.
5662         * program-state.h (sm_state_map::iterator_t): Likewise.
5663         * supergraph.h (superedge::superedge): Specify template for base
5664         class initializer.
5666 2020-01-23  David Malcolm  <dmalcolm@redhat.com>
5668         PR analyzer/93375
5669         * supergraph.cc (callgraph_superedge::get_arg_for_parm): Fail
5670         gracefully is the number of parameters at the callee exceeds the
5671         number of arguments at the call stmt.
5672         (callgraph_superedge::get_parm_for_arg): Likewise.
5674 2020-01-22  David Malcolm  <dmalcolm@redhat.com>
5676         PR analyzer/93382
5677         * program-state.cc (sm_state_map::on_svalue_purge): If the
5678         entry survives, but the origin is being purged, then reset the
5679         origin to null.
5681 2020-01-22  David Malcolm  <dmalcolm@redhat.com>
5683         * sm-signal.cc: Fix nesting of CHECKING_P and namespace ana.
5685 2020-01-22  David Malcolm  <dmalcolm@redhat.com>
5687         PR analyzer/93378
5688         * engine.cc (setjmp_svalue::compare_fields): Update for
5689         replacement of m_enode with m_setjmp_record.
5690         (setjmp_svalue::add_to_hash): Likewise.
5691         (setjmp_svalue::get_index): Rename...
5692         (setjmp_svalue::get_enode_index): ...to this.
5693         (setjmp_svalue::print_details): Update for replacement of m_enode
5694         with m_setjmp_record.
5695         (exploded_node::on_longjmp): Likewise.
5696         * exploded-graph.h (rewind_info_t::m_enode_origin): Replace...
5697         (rewind_info_t::m_setjmp_record): ...with this.
5698         (rewind_info_t::rewind_info_t): Update for replacement of m_enode
5699         with m_setjmp_record.
5700         (rewind_info_t::get_setjmp_point): Likewise.
5701         (rewind_info_t::get_setjmp_call): Likewise.
5702         * region-model.cc (region_model::dump_summary_of_map): Likewise.
5703         (region_model::on_setjmp): Likewise.
5704         * region-model.h (struct setjmp_record): New struct.
5705         (setjmp_svalue::m_enode): Replace...
5706         (setjmp_svalue::m_setjmp_record): ...with this.
5707         (setjmp_svalue::setjmp_svalue): Update for replacement of m_enode
5708         with m_setjmp_record.
5709         (setjmp_svalue::clone): Likewise.
5710         (setjmp_svalue::get_index): Rename...
5711         (setjmp_svalue::get_enode_index): ...to this.
5712         (setjmp_svalue::get_exploded_node): Replace...
5713         (setjmp_svalue::get_setjmp_record): ...with this.
5715 2020-01-22  David Malcolm  <dmalcolm@redhat.com>
5717         PR analyzer/93316
5718         * analyzer.cc (is_setjmp_call_p): Check for "setjmp" as well as
5719         "_setjmp".
5721 2020-01-22  David Malcolm  <dmalcolm@redhat.com>
5723         PR analyzer/93307
5724         * analysis-plan.h: Wrap everything namespace "ana".
5725         * analyzer-logging.cc: Likewise.
5726         * analyzer-logging.h: Likewise.
5727         * analyzer-pass.cc (pass_analyzer::execute): Update for "ana"
5728         namespace.
5729         * analyzer-selftests.cc: Wrap everything namespace "ana".
5730         * analyzer-selftests.h: Likewise.
5731         * analyzer.h: Likewise for forward decls of types.
5732         * call-string.h: Likewise.
5733         * checker-path.cc: Likewise.
5734         * checker-path.h: Likewise.
5735         * constraint-manager.cc: Likewise.
5736         * constraint-manager.h: Likewise.
5737         * diagnostic-manager.cc: Likewise.
5738         * diagnostic-manager.h: Likewise.
5739         * engine.cc: Likewise.
5740         * engine.h: Likewise.
5741         * exploded-graph.h: Likewise.
5742         * function-set.cc: Likewise.
5743         * function-set.h: Likewise.
5744         * pending-diagnostic.cc: Likewise.
5745         * pending-diagnostic.h: Likewise.
5746         * program-point.cc: Likewise.
5747         * program-point.h: Likewise.
5748         * program-state.cc: Likewise.
5749         * program-state.h: Likewise.
5750         * region-model.cc: Likewise.
5751         * region-model.h: Likewise.
5752         * sm-file.cc: Likewise.
5753         * sm-malloc.cc: Likewise.
5754         * sm-pattern-test.cc: Likewise.
5755         * sm-sensitive.cc: Likewise.
5756         * sm-signal.cc: Likewise.
5757         * sm-taint.cc: Likewise.
5758         * sm.cc: Likewise.
5759         * sm.h: Likewise.
5760         * state-purge.h: Likewise.
5761         * supergraph.cc: Likewise.
5762         * supergraph.h: Likewise.
5764 2020-01-21  David Malcolm  <dmalcolm@redhat.com>
5766         PR analyzer/93352
5767         * region-model.cc (int_cmp): Rename to...
5768         (array_region::key_cmp): ...this, using key_t rather than int.
5769         Rewrite in terms of comparisons rather than subtraction to
5770         ensure qsort is anti-symmetric when handling extreme values.
5771         (array_region::walk_for_canonicalization): Update for above
5772         renaming.
5773         * region-model.h (array_region::key_cmp): New decl.
5775 2020-01-17  David Malcolm  <dmalcolm@redhat.com>
5777         PR analyzer/93290
5778         * region-model.cc (region_model::eval_condition_without_cm): Avoid
5779         gcc_unreachable for unexpected operations for the case where
5780         we're comparing an svalue against itself.
5782 2020-01-17  David Malcolm  <dmalcolm@redhat.com>
5784         PR analyzer/93281
5785         * region-model.cc
5786         (region_model::convert_byte_offset_to_array_index): Convert to
5787         ssizetype before dividing by byte_size.  Use fold_binary rather
5788         than fold_build2 to avoid needlessly constructing a tree for the
5789         non-const case.
5791 2020-01-15  David Malcolm  <dmalcolm@redhat.com>
5793         * engine.cc (class impl_region_model_context): Fix comment.
5795 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5797         PR analyzer/93212
5798         * region-model.cc (make_region_for_type): Use
5799         FUNC_OR_METHOD_TYPE_P rather than comparing against FUNCTION_TYPE.
5800         * region-model.h (function_region::function_region): Likewise.
5802 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5804         * program-state.cc (sm_state_map::clone_with_remapping): Copy
5805         m_global_state.
5806         (selftest::test_program_state_merging_2): New selftest.
5807         (selftest::analyzer_program_state_cc_tests): Call it.
5809 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5811         * checker-path.h (checker_path::get_checker_event): New function.
5812         (checker_path): Add DISABLE_COPY_AND_ASSIGN; make fields private.
5813         * diagnostic-manager.cc
5814         (diagnostic_manager::prune_for_sm_diagnostic): Replace direct
5815         access to checker_path::m_events with accessor functions.  Fix
5816         overlong line.
5817         (diagnostic_manager::prune_interproc_events): Replace direct
5818         access to checker_path::m_events with accessor functions.
5819         (diagnostic_manager::finish_pruning): Likewise.
5821 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5823         * checker-path.h (checker_event::clone): Delete vfunc decl.
5824         (debug_event::clone): Delete vfunc impl.
5825         (custom_event::clone): Delete vfunc impl.
5826         (statement_event::clone): Delete vfunc impl.
5827         (function_entry_event::clone): Delete vfunc impl.
5828         (state_change_event::clone): Delete vfunc impl.
5829         (start_cfg_edge_event::clone): Delete vfunc impl.
5830         (end_cfg_edge_event::clone): Delete vfunc impl.
5831         (call_event::clone): Delete vfunc impl.
5832         (return_event::clone): Delete vfunc impl.
5833         (setjmp_event::clone): Delete vfunc impl.
5834         (rewind_from_longjmp_event::clone): Delete vfunc impl.
5835         (rewind_to_setjmp_event::clone): Delete vfunc impl.
5836         (warning_event::clone): Delete vfunc impl.
5838 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5840         * supergraph.cc (supernode::dump_dot): Ensure that the TABLE
5841         element has at least one TR.
5843 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5845         PR analyzer/58237
5846         * engine.cc (leak_stmt_finder::find_stmt): Use get_pure_location
5847         when comparing against UNKNOWN_LOCATION.
5848         (stmt_requires_new_enode_p): Likewise.
5849         (exploded_graph::dump_exploded_nodes): Likewise.
5850         * supergraph.cc (supernode::get_start_location): Likewise.
5851         (supernode::get_end_location): Likewise.
5853 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5855         PR analyzer/58237
5856         * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
5857         selftest::analyzer_sm_file_cc_tests.
5858         * analyzer-selftests.h (selftest::analyzer_sm_file_cc_tests): New
5859         decl.
5860         * sm-file.cc: Include "analyzer/function-set.h" and
5861         "analyzer/analyzer-selftests.h".
5862         (get_file_using_fns): New function.
5863         (is_file_using_fn_p): New function.
5864         (fileptr_state_machine::on_stmt): Return true for known functions.
5865         (selftest::analyzer_sm_file_cc_tests): New function.
5867 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5869         * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
5870         selftest::analyzer_sm_signal_cc_tests.
5871         * analyzer-selftests.h (selftest::analyzer_sm_signal_cc_tests):
5872         New decl.
5873         * sm-signal.cc: Include "analyzer/function-set.h" and
5874         "analyzer/analyzer-selftests.h".
5875         (get_async_signal_unsafe_fns): New function.
5876         (signal_unsafe_p): Reimplement in terms of the above.
5877         (selftest::analyzer_sm_signal_cc_tests): New function.
5879 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5881         * analyzer-selftests.cc (selftest::run_analyzer_selftests): Call
5882         selftest::analyzer_function_set_cc_tests.
5883         * analyzer-selftests.h (selftest::analyzer_function_set_cc_tests):
5884         New decl.
5885         * function-set.cc: New file.
5886         * function-set.h: New file.
5888 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5890         * analyzer.h (fndecl_has_gimple_body_p): New decl.
5891         * engine.cc (impl_region_model_context::on_unknown_change): New
5892         function.
5893         (fndecl_has_gimple_body_p): Make non-static.
5894         (exploded_node::on_stmt): Treat __analyzer_dump_exploded_nodes as
5895         known.  Track whether we have a call with unknown side-effects and
5896         pass it to on_call_post.
5897         * exploded-graph.h (impl_region_model_context::on_unknown_change):
5898         New decl.
5899         * program-state.cc (sm_state_map::on_unknown_change): New function.
5900         * program-state.h (sm_state_map::on_unknown_change): New decl.
5901         * region-model.cc: Include "bitmap.h".
5902         (region_model::on_call_pre): Return a bool, capturing whether the
5903         call has unknown side effects.
5904         (region_model::on_call_post): Add arg "bool unknown_side_effects"
5905         and if true, call handle_unrecognized_call.
5906         (class reachable_regions): New class.
5907         (region_model::handle_unrecognized_call): New function.
5908         * region-model.h (region_model::on_call_pre): Return a bool.
5909         (region_model::on_call_post): Add arg "bool unknown_side_effects".
5910         (region_model::handle_unrecognized_call): New decl.
5911         (region_model_context::on_unknown_change): New vfunc.
5912         (test_region_model_context::on_unknown_change): New function.
5914 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5916         * diagnostic-manager.cc (saved_diagnostic::operator==): Move here
5917         from header.  Replace pointer equality test on m_var with call to
5918         pending_diagnostic::same_tree_p.
5919         * diagnostic-manager.h (saved_diagnostic::operator==): Move to
5920         diagnostic-manager.cc.
5921         * pending-diagnostic.cc (pending_diagnostic::same_tree_p): New.
5922         * pending-diagnostic.h (pending_diagnostic::same_tree_p): New.
5923         * sm-file.cc (file_diagnostic::subclass_equal_p): Replace pointer
5924         equality on m_arg with call to pending_diagnostic::same_tree_p.
5925         * sm-malloc.cc (malloc_diagnostic::subclass_equal_p): Likewise.
5926         (possible_null_arg::subclass_equal_p): Likewise.
5927         (null_arg::subclass_equal_p): Likewise.
5928         (free_of_non_heap::subclass_equal_p): Likewise.
5929         * sm-pattern-test.cc (pattern_match::operator==): Likewise.
5930         * sm-sensitive.cc (exposure_through_output_file::operator==):
5931         Likewise.
5932         * sm-taint.cc (tainted_array_index::operator==): Likewise.
5934 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5936         * diagnostic-manager.cc (dedupe_winners::add): Add logging
5937         of deduplication decisions made.
5939 2020-01-14  David Malcolm  <dmalcolm@redhat.com>
5941         * ChangeLog: New file.
5942         * analyzer-selftests.cc: New file.
5943         * analyzer-selftests.h: New file.
5944         * analyzer.opt: New file.
5945         * analysis-plan.cc: New file.
5946         * analysis-plan.h: New file.
5947         * analyzer-logging.cc: New file.
5948         * analyzer-logging.h: New file.
5949         * analyzer-pass.cc: New file.
5950         * analyzer.cc: New file.
5951         * analyzer.h: New file.
5952         * call-string.cc: New file.
5953         * call-string.h: New file.
5954         * checker-path.cc: New file.
5955         * checker-path.h: New file.
5956         * constraint-manager.cc: New file.
5957         * constraint-manager.h: New file.
5958         * diagnostic-manager.cc: New file.
5959         * diagnostic-manager.h: New file.
5960         * engine.cc: New file.
5961         * engine.h: New file.
5962         * exploded-graph.h: New file.
5963         * pending-diagnostic.cc: New file.
5964         * pending-diagnostic.h: New file.
5965         * program-point.cc: New file.
5966         * program-point.h: New file.
5967         * program-state.cc: New file.
5968         * program-state.h: New file.
5969         * region-model.cc: New file.
5970         * region-model.h: New file.
5971         * sm-file.cc: New file.
5972         * sm-malloc.cc: New file.
5973         * sm-malloc.dot: New file.
5974         * sm-pattern-test.cc: New file.
5975         * sm-sensitive.cc: New file.
5976         * sm-signal.cc: New file.
5977         * sm-taint.cc: New file.
5978         * sm.cc: New file.
5979         * sm.h: New file.
5980         * state-purge.cc: New file.
5981         * state-purge.h: New file.
5982         * supergraph.cc: New file.
5983         * supergraph.h: New file.
5985 2019-12-13  David Malcolm  <dmalcolm@redhat.com>
5987         * Initial creation
5990 Copyright (C) 2019-2021 Free Software Foundation, Inc.
5992 Copying and distribution of this file, with or without modification,
5993 are permitted in any medium without royalty provided the copyright
5994 notice and this notice are preserved.