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