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